I created a new wpf window and set the background of the main Grid, I found there is a blank space on the top of window when I set WindowStyle to be None. How to remove the blank space?
<Window x:Class="XuanyiRetail.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" WindowStyle="None">
<Grid Background="Bisque">
</Grid>
Set these propertys will be OK!
WindowStyle="None"
ResizeMode="CanResizeWithGrip"
AllowsTransparency="True"
Not only on top but also on the three other edges are white borders visible.
There has to be an Style in your Project, which defines a Margin for the Type Grid.
Something like Margin="1,5,1,1"
<Style TargetType="{x:Type Grid}">
<Setter Property="Margin" Value="1,5,1,1"/>
</Style>
To make sure this is the source of the error you could just define a style without a margin in that window.
<Window.Resources>
<Style x:Key="NoMarginGrid" TargetType="{x:Type Grid}">
<Setter Property="Margin" Value="0"/>
</Style>
</Window.Resources>
<Grid Background="Bisque" Style="{StaticResource NoMarginGrid}" >
</Grid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With