有人可以告诉我为什么这个触发器不起作用:
<!--Style-->
<Style x:Key="Test" TargetType="{x:Type Expander}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="IsExpanded" Value="false"></Setter>
</Trigger>
</Style.Triggers>
</Style>
<!-- Syle applyed in expander -->
<Expander Header="Expander" Margin="40,89,118,0" Name="expander1" Height="23" VerticalAlignment="Top" >
<Grid>
<Ellipse Height="100" Margin="86,0,-8,-58" Name="ellipse1" Stroke="Black" VerticalAlignment="Bottom" />
</Grid>
</Expander>
<!-- Code Behind -->
private void button1_Click(object sender, RoutedEventArgs e)
{
this.expander1.IsEnabled = false;
}
我尝试了其他方式,但没有成功。当扩展器被禁用时,有另一种方式来折叠内容。