C# 展开时更改扩展器标题文本
我有一个扩张器,它将收割台旋转-90度:C# 展开时更改扩展器标题文本,c#,wpf,xaml,C#,Wpf,Xaml,我有一个扩张器,它将收割台旋转-90度: <Expander Name="exProduct" Grid.Column="1" ExpandDirection="Left" HorizontalAlignment="Right" VerticalAlignment="Stretch"> <Expander.Header> <TextBlock Text="Add Product" FontSize="18"
<Expander Name="exProduct" Grid.Column="1" ExpandDirection="Left"
HorizontalAlignment="Right" VerticalAlignment="Stretch">
<Expander.Header>
<TextBlock Text="Add Product" FontSize="18"
<TextBlock.LayoutTransform>
<RotateTransform Angle="-90"/>
</TextBlock.LayoutTransform>
</TextBlock>
</Expander.Header>
您想隐藏标题还是只更改文本?您的代码应该可以工作。只需从样式外部删除标题。也就是说,仅在样式中设置标题。
<Window.Resources>
<Style x:Key="ExpanderEx" TargetType="Expander">
<Setter Property="Header" Value="Show"/>
<Style.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter Property="Header" Value="Hide"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Expander Style="{StaticResource ExpanderEx}" >
<StackPanel>
<Button Width="100" Height="50"/>
</StackPanel>
</Expander>