在wpf窗口顶部的空白

时间:2015-11-24 12:04:47

标签: wpf

enter image description here

我创建了一个新的wpf窗口并设置了主Grid的背景,当我将WindowStyle设置为None时,我发现窗口顶部有一个空白区域。 如何删除空格?

<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>

2 个答案:

答案 0 :(得分:1)

不仅在顶部而且在其他三个边缘上都可见白色边框。

项目中必须有一个样式,它定义了类型网格的边距。

Margin =&#34; 1,5,1,1&#34;

之类的东西
<Style TargetType="{x:Type Grid}">
   <Setter Property="Margin" Value="1,5,1,1"/>
</Style>

要确保这是错误的来源,您只需在该窗口中定义没有边距的样式。

<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>

答案 1 :(得分:1)

设置这些属性就可以了!

WindowStyle="None"  
ResizeMode="CanResizeWithGrip"
AllowsTransparency="True"
相关问题