wpf 如何在堆栈面板中并排对齐?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12596996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 05:33:04 来源:igfitidea点击:
How do I align side by side in stackpanel?
提问by Alvin
How can I have the button align beside the ComboBox? I am not able to drag the button to the side of the ComboBoxusing designer.
我怎样才能让按钮在 旁边对齐ComboBox?我无法将按钮拖到ComboBox使用设计器的一侧。
<Expander.Content>
<StackPanel>
<ComboBox Name="cbProd" Height="30" IsEditable="True" FontSize="15" />
<Button Name="btnAdd" Content="add" Click="btnAddProduct_Click" />
回答by SvenG
Just nest multiple layout containers like this:
只需像这样嵌套多个布局容器:
<Expander.Content>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<ComboBox Name="cbProd" Height="30" IsEditable="True" FontSize="15" />
<Button Name="btnAdd" Content="add" Click="btnAddProduct_Click" />
</StackPanel>
... your other controls
</StackPanel>
</Expander.Content>
回答by dnr3
set the orientation property of the stackpanel to Horizontal
将堆栈面板的方向属性设置为水平

