【问题标题】:DockPanel Floating ElementDockPanel 浮动元素
【发布时间】:2013-12-22 17:35:12
【问题描述】:

我有一个包含两个元素的 DockPanel。第一个元素需要跨越整个 DockPanel。第二个元素需要右对齐,但“浮动”在另一个元素的顶部。 当我注释掉第二个元素时,第一个元素确实跨越了整个停靠面板,它看起来很合适。当我有第二个元素时,它会推动第一个元素并将其压扁。

                <DockPanel HorizontalAlignment="Stretch" Margin="6,8,0,8" Grid.Row="1" Grid.Column="0">
                    <shared:YesNoControl Panel.ZIndex="0"></shared:YesNoControl>
                    <extended:IntegerUpDown Panel.ZIndex="1" Height="25" HorizontalAlignment="Right" Width="100"></extended:IntegerUpDown>
                </DockPanel>

我怎样才能得到这个效果?我基本上希望第二个元素甚至不影响第一个元素,而只是出现在它之上。

【问题讨论】:

  • 我相信这正是 DockPanel 的运作方式。您可能必须将浮动控件从 DockPanel 中拉出,然后将它和 DockPanel 放入其他东西中。

标签: wpf dockpanel


【解决方案1】:

使用边距试试这个简单的方法:

<DockPanel Grid.Row="2" HorizontalAlignment="Stretch">
    <TextBox Background="AliceBlue" Text="This is a text box contains a great deal of useless text!!!!" />
    <Button  Width="20" Height="20" Margin="-20,0,0,0" />
</DockPanel>

按钮覆盖了文本,因此它看起来像是“悬停”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-23
    • 2012-01-08
    • 2011-11-06
    • 1970-01-01
    • 1970-01-01
    • 2011-02-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多