WPF页边距不小于';不算

WPF页边距不小于';不算,wpf,grid,Wpf,Grid,我刚开始使用WPF,我正在尝试建立一个网格,其中有四行高度为150。这将占用我为高度设置的800像素中的600像素。然后,我将上边距设置为30,下边距设置为170,以便给自己一些控制底部的空间 在设计视图中,一切看起来都很棒,但当我运行我的应用程序时,最下面一行有一些区域被切断 设计视图 运行视图 我不明白是什么导致了这些观点之间的差异 <Page x:Class="EzTargetProject.HomePage" xmlns="http://schemas.microsoft

我刚开始使用WPF,我正在尝试建立一个网格,其中有四行高度为150。这将占用我为高度设置的800像素中的600像素。然后,我将上边距设置为30,下边距设置为170,以便给自己一些控制底部的空间

在设计视图中,一切看起来都很棒,但当我运行我的应用程序时,最下面一行有一些区域被切断

设计视图

运行视图

我不明白是什么导致了这些观点之间的差异

 <Page x:Class="EzTargetProject.HomePage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  mc:Ignorable="d" 
  d:DesignHeight="800" d:DesignWidth="1280"
Title="HomePage">

<Grid  Margin="20,30,20, 170" Grid.Column="4" Grid.Row="4" Background="Gray" ShowGridLines="True">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="150"/>
        <RowDefinition Height="150"/>
        <RowDefinition Height="150"/>
        <RowDefinition Height="150"/>
    </Grid.RowDefinitions>

    <!-- Name -->
    <StackPanel Grid.Column="0" Grid.Row="0" Orientation="Vertical" />
</Grid>


如果要设置网格的高度,可以避免底部边距

如果你总是想有一个600像素高的网格,只需设置它

我将使用ScrollViewer作为父级,让用户看到要在网格下设置的控件(例如,如果用户希望有一个小窗口):

我可能已经注意到问题所在,但如果有人能给我一个,我希望得到确认。页边距是否考虑了页面的导航栏,这意味着无论导航栏有多少像素,我的页边距都会减少?这一点非常有效,使我的设计在其他屏幕上更加灵活。我会在5分钟内给你答案,当它允许我。谢谢。顺便说一句,上面的方法是不是因为导航栏而不起作用?我想是因为它总是试图让边距。。。在电网下没有170px。我不知道窗口是否比设计窗口小,或者窗口底部是否分配给了另一个元素8-)