我刚开始使用WPF(而不是winforms),并试图创建一个固定大小的窗口(请参见图像)。匹配网格和窗口大小WPF
问题是,每当我运行应用程序右下角被搞砸了,有附近的按钮和边缘之间的零空间。 (见其他图)
这里是XAML代码(大多是由Visual Studio设计产生)
<Window x:Class="UseCaseHelper.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:UseCaseHelper"
mc:Ignorable="d"
Title="UseCaseHelper" Height="500" Width="900">
<Grid>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"/>
<Button x:Name="button1" Content="Button" HorizontalAlignment="Left" Margin="809,441,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
</Window>
我试过google搜索没有成功的解决方案。希望有人能够指出我在这里做错了什么。
为两者使用Margin =“10”,设置VerticalAlignment = Top/Bottom和HorizontalAlignment = Left/Right。 – AnjumSKhan