如何在stackpanel中并排排列?

时间:2021-05-04 19:40:40

How can I have the button align beside the ComboBox ? I am not able to drag the button to the side of the ComboBox using designer.

如何在ComboBox旁边按下按钮?我无法使用设计器将按钮拖动到ComboBox的侧面。

<Expander.Content>
    <StackPanel>
        <ComboBox Name="cbProd" Height="30" IsEditable="True" FontSize="15" />
        <Button Name="btnAdd" Content="add" Click="btnAddProduct_Click" />

2 个解决方案

#1


21  

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>

#2


8  

set the orientation property of the stackpanel to Horizontal

将stackpanel的orientation属性设置为Horizo​​ntal

#1


21  

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>

#2


8  

set the orientation property of the stackpanel to Horizontal

将stackpanel的orientation属性设置为Horizo​​ntal