我正在试图创建一个扩展器,其中头部保持固定并且内容出现在头部上方,覆盖上面的任何其他控件。设置ExpandDirection="Up"
并将Expander放置在Canvas中可实现其中的一半 - 内容相对于标题展开并覆盖其他控件(虽然位于下方),但标题向下移动。如何使WPF扩展器向上扩展,同时保持头部固定
有没有办法做到这一点,但保持标题在一个固定的位置,以便内容结束覆盖控制上面?
这是我迄今poduced:
<Window x:Class="Sandbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="900" Width="1100">
<StackPanel>
<StackPanel Margin="20,0,0,0">
<RadioButton Content="Choice One"/>
<RadioButton Content="Choice Two"/>
<RadioButton Content="Choice Three"/>
<RadioButton Content="Choice Four"/>
<RadioButton Content="Choice Five"/>
<RadioButton Content="Choice Six"/>
</StackPanel>
<Canvas MinHeight="25" Panel.ZIndex="99">
<Expander Header="This must stay fixed" ExpandDirection="Up" Width="175">
<Grid Background="Cornsilk">
<Grid.BitmapEffect>
<DropShadowBitmapEffect />
</Grid.BitmapEffect>
<TextBlock TextWrapping="Wrap" Margin="5">
This must expand upwards, not downwards.
The header must remain exactly where it is.
This TextBlock must appear above the header
and overlay the top radio buttons instead.
</TextBlock>
</Grid>
</Expander>
</Canvas>
<StackPanel Margin="20,0,0,0">
<RadioButton Content="Choice One"/>
<RadioButton Content="Choice Two"/>
<RadioButton Content="Choice Three"/>
<RadioButton Content="Choice Four"/>
<RadioButton Content="Choice Five"/>
<RadioButton Content="Choice Six"/>
</StackPanel>
</StackPanel>
</Window>
谢谢!这比我一直在尝试的解决方案效果更好 - 修改Expander的ControlTemplate。我可以使用Popup解决方案摆脱Canvas。我只需要调整ToggleButton的样式,使它看起来类似于Expander切换按钮。 – Neo 2010-12-09 15:52:32