本文介绍了DockPanel.Dock=“右"不适用于最大化窗口上的单个控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 DockPanel.Dock 在特定位置(即左/右)停靠控件.问题是我的控件没有根据 DockPanel.Dock 位置停靠.
I am using DockPanel.Dock for docking controls at the specific place(i.e left/right). The problem is my controls are not docking according to the DockPanel.Dock position.
下面是带有DockPanel.Dock="Right"
<DockPanel>
<TextBlock
Text ="Left1"
Margin ="5"
DockPanel.Dock ="Left"
Style ="{StaticResource TextBlockStyle}"
/>
<TextBlock
Text ="Left2"
Margin ="5"
DockPanel.Dock ="Left"
Style ="{StaticResource TextBlockStyle}"
/>
<TextBlock
Text ="Right1"
Margin ="5"
DockPanel.Dock ="Right"
Style ="{StaticResource TextBlockStyle}"
/>
</DockPanel>
DockPanel.Dock="Right"
<DockPanel>
<TextBlock
Text ="Left1"
Margin ="5"
DockPanel.Dock ="Left"
Style ="{StaticResource TextBlockStyle}"
/>
<TextBlock
Text ="Left2"
Margin ="5"
DockPanel.Dock ="Left"
Style ="{StaticResource TextBlockStyle}"
/>
<TextBlock
Text ="Right1"
Margin ="5"
DockPanel.Dock ="Right"
Style ="{StaticResource TextBlockStyle}"
/>
<TextBlock
Text ="Right2"
Margin ="5"
DockPanel.Dock ="Right"
Style ="{StaticResource TextBlockStyle}"
/>
</DockPanel>
预期输出:
任何想法或想法将不胜感激.提前致谢
Any idea or thought will be appreciated. Thanks in Advance
推荐答案
你应该使用 LastChildFill
属性:
<DockPanel LastChildFill="False">
<TextBlock
Text ="Left1"
Margin ="5"
DockPanel.Dock ="Left"
/>
<TextBlock
Text ="Left2"
Margin ="5"
DockPanel.Dock ="Left"
/>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
<TextBlock
Text ="Right1"
Margin ="5"
/>
<TextBlock
Text ="Right2"
Margin ="5"
/>
</StackPanel>
</DockPanel>
这篇关于DockPanel.Dock=“右"不适用于最大化窗口上的单个控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!