我的.xaml
中有以下代码:
<StackPanel
Orientation="Horizontal"
DockPanel.Dock="Top" Background="Yellow"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="0,2,2,0"
Name="MainButtonsPanel"
Width="100" >
<Button Name="ButtonSaveChanges"
Background="LightGray"
Width="100"
Height="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}"
Command="{Binding MyCommand}"
CommandParameter="{Binding}" Visibility="Visible" />
<Button Name="ButtonEdit"
Background="Gray"
Width="100"
Height="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}"
Command="{Binding MyCommand}"
CommandParameter="{Binding}" />
</StackPanel>
它在运行时看起来像这样:
我希望灰色方块与右边对齐。我尝试使用VerticalContentAlignment
,但在我编写它时,它并没有出现在我的.xaml
元素中...
关于如何实现这一点的任何想法?
答案 0 :(得分:1)
StackPanel有一个名为“FlowDirection”的属性。这是你在找什么?
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="Yellow" HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="0,2,2,0" Name="MainButtonsPanel" Width="400" FlowDirection="RightToLeft">