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