我剛開始使用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