Is it possible to remove the white strip on top of WPF window with Window Style=None. XAML and Window is shown in the screenshot:
32
votes
I can't see anything in the visual tree that's causing this but I can reproduce it on Windows 10. I wonder whether that happens in prior Windows versions, too. Maybe it's a bug introduced due to differences in how the window layout and borders are handled.
- Joey
Possible duplicate of How to create custom window chrome in wpf?
- devuxer
4 Answers
41
votes
What you are seeing in white is the re-size border. You can remove that and still make the window resizable by setting ResizeMode="CanResizeWithGrip" AllowsTransparency="True"
If you dont want to resize at all then do this - ResizeMode="NoResize", again you wont see the border but you cant resize.
<Window x:Class="HandsOnSolution.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Background="Green" WindowStyle="None" ResizeMode="CanResizeWithGrip" AllowsTransparency="True">
<Grid>
</Grid>
</Window>
Edit
Good point by @devuxer, if you are interested in dragging you can add this piece of code to the window mouse down event
<Window MouseLeftButtonDown="Window_MouseLeftButtonDown"/>
//code behind
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
16
votes
I had been hunting for a solution for a couple of days now, in simple words this link held the answer to my queries
though the code snippet that did the magic was:
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="0"
CornerRadius="2"
GlassFrameThickness="0"
NonClientFrameEdges="None"
ResizeBorderThickness="3"/>
</Setter.Value>
</Setter>
I just added the above property setter to the custom Window Style.
Hope that helped :)
13
votes
