【问题标题】:How to properly dock right more than one element, WPF如何正确停靠多个元素,WPF
【发布时间】:2018-10-28 03:44:38
【问题描述】:

我不知道为什么当我正确停靠时,最后一个控件没有正确停靠。这是我的 DockPanel 示例:

<DockPanel>
    <Button Content="A" DockPanel.Dock="Right"/>
    <Button Content="B" DockPanel.Dock="Right"/>
    <Button Content="C" DockPanel.Dock="Right"/>
</DockPanel>

在此示例中,“C”按钮未正确停靠。 你知道怎么解决吗?

【问题讨论】:

    标签: c# wpf docking dockpanel


    【解决方案1】:

    有一个名为LastChildFill 的属性被赋予了错误的默认值。将其设置为 false:

    <DockPanel LastChildFill="False"> 
        <Button Content="A" DockPanel.Dock="Right"/>
        <Button Content="B" DockPanel.Dock="Right"/>
        <Button Content="C" DockPanel.Dock="Right"/>
    </DockPanel>
    

    【讨论】:

    • 谢谢! DockPanel 中的最后一个子元素会伸展以填充剩余的可用空间 (MSDN)。
    猜你喜欢
    • 2013-01-03
    • 2013-11-24
    • 1970-01-01
    • 1970-01-01
    • 2015-05-20
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多