I have found that using WindowChrome on a WPF Window can make me put content wherever I want in the Window, which is a great thought. Now I can finally make the title bar have the same color as the rest of my application.
However, I still like the default minimize/maximize/close buttons that appear on a non styled Window.
Is there any way I can style my Window using WindowChrome yet still preserve the default buttons?
<Style x:Key="MainWindow" TargetType="{x:Type Window}">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="30" ResizeBorderThickness="5" />
</Setter.Value>
</Setter>
</Style>
<Window Style="{StaticResource MainWindow}">
<Grid Background="Black">
<MyContent />
</Grid>
</Window>
This makes a big black window (great!) but without any min/max/close buttons as they are hidden behind the Grid
(not so great). The buttons are still clickable, though, so they're obviously there.
Before Windows 10 was introduced, you can customize your
Window.Template
by addingMargin
property on your outsideBorder
. Just like the code below.The code above does these things:
WindowChrome
to make our controls showing above windows none client areas.Margin
property to negative numbers such as0 -30 0 0
.But after Windows 10, especially the Windows 10 Creators Update, you can no longer show windows default buttons with an acceptable window style. It would always show a themed border around, ugly!
The code above may work in earlier versions of Windows 10. I mean, not as ugly as that on Creators Update.
No, I don't think so. You can set the
GlassFrameThickness
property to0
to disable the buttons and then you will have to create your own custom ones I am afraid. You could refer to the following project for some examples: https://wpfwindow.codeplex.com/.If you want Window 10 style caption buttons you could use the
Segoe MDL2 Assets
font family: