0
XAML爲UWP應用程序(我的第一次真正的嘗試)控制在堆棧面板中未對齊
我在網格中有一個堆棧面板,方向爲水平。我想按順序顯示一個按鈕,一個文本塊和另外兩個按鈕。
堆棧面板佔用自己的一排網格。
在堆疊面板中,兩個按鈕沒有對齊到右側邊框。他們在75%的位置閒逛。使用HorizontalOrientation歸因對這兩個按鈕標籤沒有任何影響。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal">
<Button x:Name="btnShow" Margin="0,0,5,0">Show</Button>
<TextBlock HorizontalAlignment="Stretch">Nothing searched for yet</TextBlock>
<Button x:Name="btnLeft" HorizontalAlignment="Right" Margin="5,0,5,0"><</Button>
<Button x:Name="btnRight" HorizontalAlignment="Right">></Button>
</StackPanel></Grid></Grid>
不是在按鈕上設置'HorizontalAlignment ='Right'',而是在'StackPanel'上設置它。 – AVK
這只是將整個組向右側移動,留下了一個很大的缺口 – VinceP1974
用'Width *'將另一列添加到網格並將TextBox移動到該列。最後一列應該只包含您想要移動到右側的按鈕。 – AVK