我在实现我想要的布局时遇到问题。这是我的代码:
<DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" LastChildFill="True">
<Label DockPanel.Dock="Left" Content="Add new:"/>
<Button DockPanel.Dock="Right" Content="Add" VerticalAlignment="Center"/>
<ComboBox VerticalAlignment="Center" MaxWidth="150" HorizontalAlignment="Stretch">
<System:String>Item1</System:String>
<System:String>Item2</System:String>
<System:String>Item3</System:String>
</ComboBox>
</DockPanel>
我想要的是让三个元素按标签、组合框、按钮的顺序向右对齐。标签和按钮应该占用尽可能多的空间,但我希望ComboBox占用尽可能多的空间,最多150 像素。当 DockPanel 未设置为 HorizontalAlignment=Right 时,它会起作用。
任何提示/解决方案?
谢谢。