2015-06-17 88 views
0

我在下面的代碼我.xamlHorizo​​ntalContentAlignment不會出現

<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> 

它看起來像這樣運行:

enter image description here

我想要的灰色方塊對齊到對。我嘗試使用VerticalContentAlignment,但當我編寫它時,它不會出現在我的.xaml元素中...

有關如何實現這一點的任何想法?

回答

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">

enter image description here

+0

完全是...謝謝!所以新手......:P – Sonhja

相關問題