【发布时间】:2010-11-30 19:06:47
【问题描述】:
我有两个停靠面板,每个停靠面板都有一个左侧 StackPanel。
bottom StackPanel 的宽度由 text 的宽度决定。
top StackPanel 的宽度应该与 bottom StackPanel 的宽度相同。
我尝试通过 ElementName 将顶部 StackPanel 的宽度绑定到底部 StackPanel 的宽度,但这不起作用。
如何使顶部宽度与底部宽度相同?
<StackPanel>
<DockPanel LastChildFill="True" Height="100" >
<StackPanel Width="{Binding ElementName=LeftMenuText, Path=Width}"
DockPanel.Dock="Left"
Background="Yellow">
<TextBlock
Text="This is some text."/>
</StackPanel>
<StackPanel DockPanel.Dock="Right"
Background="Orange">
</StackPanel>
</DockPanel>
<DockPanel
Height="3"
Background="Black"></DockPanel>
<DockPanel LastChildFill="True" Height="100">
<StackPanel Name="LeftMenuWrapper"
DockPanel.Dock="Left"
Background="Yellow">
<TextBlock
Text="This is some text that is longer."/>
</StackPanel>
<StackPanel DockPanel.Dock="Right"
Background="Blue">
</StackPanel>
</DockPanel>
</StackPanel>
【问题讨论】:
标签: wpf xaml width stackpanel dockpanel