Neo*_*Neo 1 wpf overlay canvas fixed expander
我正在尝试创建一个扩展器,其中标题保持固定,内容显示在标题上方,覆盖上面的任何其他控件。在 Canvas 中设置ExpandDirection="Up"和放置 Expander 可以实现一半的效果 - 内容相对于标题向上展开,并覆盖其他控件(尽管在下面),但标题向下移动。
有什么方法可以做到这一点,但将标题保持在固定位置,以便内容最终覆盖上面的控件?
这是我到目前为止所发布的内容:
<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>
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以使用 ToggleButton 和 Popup 代替 Expander:
<Canvas MinHeight="25" Panel.ZIndex="99">
<ToggleButton x:Name="toggle" Content="This must stay fixed" Width="175" />
<Popup Placement="Top" PlacementTarget="{Binding ElementName=toggle}"
IsOpen="{Binding ElementName=toggle, Path=IsChecked}">
<Grid Background="Cornsilk" Width="175">
<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>
</Popup>
</Canvas>
Run Code Online (Sandbox Code Playgroud)