我正试图区分单击时切换按钮的状态。我有下面的代码片段。
然而,当在样式中将IsChecked值设置为“True”时,此方法无效。 当设置为false时,它有效。
我想知道原因。 有任何答案!
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="OnOffToggleImageStyle" TargetType="ToggleButton">
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="DimGray"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<ToggleButton Height="60" Content="Text" Style="{StaticResource OnOffToggleImageStyle}">
</ToggleButton>
</Grid>
</Window>
然而,当在样式中将IsChecked值设置为“True”时,此方法无效。 当设置为false时,它有效。
我想知道原因。 有任何答案!