我有以下的code:
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<RadioButton Content="_Programs"
IsChecked="{Binding Path=ProgramBanksSelected}" IsEnabled="{Binding Path=ProgramsEnabled}" Margin="8" />
<StackPanel>
<Label Content="Master" Height="28" Name="MasterFileStatus" VerticalContentAlignment="Center"/>
</StackPanel>
</StackPanel>
...
的单选按钮,应放置在左侧的堆叠面板(Ⅰ除去某些按钮不弄乱例子)和标签(我把暂时在嵌套StackPanel中)应在右侧。
The radio button should be placed on the left side in the stack panel (I removed some buttons for not cluttering the example) and the label (which I put temporarily in a nested StackPanel) should be on the right side.
我已经试过很多路线的组合,但我不能在标签右侧。 我应该补充做到这一点?
I tried already lots of combinations of alignments but I cannot get the label on the right side. What should I add to accomplish this?
只要不使用的StackPanel
, StackPanels
堆栈的。它们,出于明显的原因,而不是允许对准在它们堆叠的方向。使用Grid,与列定义如下所示:
Just do not use a StackPanel
, StackPanels
stack. They do, for obvious reasons, not allow alignment in the direction in which they stack. Use a Grid
, with column definitions like so:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>