简体   繁体   English

如何在控件之间添加动态间距? (带图片)

[英]How do I add dynamic spacing between controls? (with pics)

My question is simple. 我的问题很简单。 What is the best way to achieve what you see the pic below in WPF? 在WPF中实现以下图片的最佳方法是什么?

At the moment this is a horizontal StackPanel, with the right padding of the checkbox set to 90. This works okay, but if you resize the window it's no good anymore, unless maybe you re-adjust the padding in the window's resize event, but that seems clunky when using a layout manager. 目前,这是一个水平的StackPanel,复选框的右侧填充设置为90。这可以正常工作,但是如果您调整窗口的大小将不再有用,除非您可能需要在窗口的resize事件中重新调整填充,但是使用布局管理器时,似乎显得笨拙。

I am coming from a Qt background, and in Qt I would use a "stretch" element between the buttons and the checkbox to push them apart dynamically. 我来自Qt背景,在Qt中,我将在按钮和复选框之间使用一个“ stretch”元素来动态地将它们分开。 Is there a similar concept in WPF? WPF中是否有类似的概念? If not, how do I achieve this so that it will support dynamic resizing? 如果没有,如何实现此目标,以便支持动态调整大小?

替代文字

Thanks! 谢谢!

Use the corrent Panel implementation, in this case a Grid would work best: 使用corrent的Panel实现,在这种情况下, Grid将最好地工作:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>

    <CheckBox>Details</CheckBox>
    <Button Grid.Column="1">Exit</Button>
    <Button Grid.Column="2">Reset</Button>
</Grid>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM