I'm trying to add a couple of things (a logo on the left and tab control items in the center) to a window chrome using the WindowChrome class. I'd like to keep the normal Win10 buttons, however, just like Google Chrome and similar applications do. Does anyone have any suggestions?
Asked
Active
Viewed 213 times
1 Answers
1
By default, WindowChrome
does not hide the caption buttons, but it expands the client area to the entire window frame, so you need to make sure that there's nothing drawn on top of these buttons, such as the window's own background. This could be achieved by setting the background brush to {x:Null}
, and also expanding the "glass" to the entire frame by setting it to -1
in order to avoid black (non-drawn) areas behind your controls.
You should also set WindowChrome.IsHitTestVisibleInChrome
to True
for the tab items (or any control in the non-client area) to make them interactive.
Here's an example:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="200"
Background="{x:Null}">
<WindowChrome.WindowChrome>
<WindowChrome GlassFrameThickness="-1" />
</WindowChrome.WindowChrome>
<TabControl Margin="{x:Static SystemParameters.WindowResizeBorderThickness}">
<TabItem WindowChrome.IsHitTestVisibleInChrome="True"
Height="{x:Static SystemParameters.WindowCaptionHeight}"
Header="TabItem" />
</TabControl>
</Window>
And here's what you'll get:

Yarik
- 1,423
- 1
- 14
- 16