我刚开始使用 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>