我试图在一个组中的单选按钮上创建一个悬停和选择效果到目前为止,它工作,但如果我悬停在一个按钮上,曾经被选中的悬停效果不工作〉悬停在一个按钮上,以前没有被选中的作品,也是isChecked状态似乎工作.还有我如何取消选择一个单选按钮的点击,使没有按钮在组中被选中.谢谢你的帮助和指点。
<Color x:Key="Hover" R="135" G="0" B="0" A="255" />
<Color x:Key="Default" R="40" G="40" B="40" A="255" />
<Color x:Key="Selected" R="0" G="255" B="0" A="255" />
<!-- // CustomRadioButton // -->
<Style TargetType="{x:Type RadioButton}" x:Key="CustomRadioButton">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border x:Name="tabRadBtn" Margin="10"
Width="60" BorderThickness="0">
<TextBlock Background="Transparent" x:Name="ToggleData"
Text="{TemplateBinding Property=Content}"
HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock.Foreground>
<SolidColorBrush x:Name="ToggleColor" Color="{StaticResource Default}"/>
</TextBlock.Foreground>
</TextBlock>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True"/>
<Condition Property="IsChecked" Value="False"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard x:Name="EnterRadioButtonHover">
<ColorAnimation Storyboard.TargetName="ToggleColor"
Storyboard.TargetProperty="Color"
To="{StaticResource Hover}" Duration="0:0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard x:Name="ExitRadioButtonHover">
<ColorAnimation Storyboard.TargetName="ToggleColor"
Storyboard.TargetProperty="Color"
To="{StaticResource Default}" Duration="0:0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsEnabled" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard x:Name="EnterRadioButtonSelect">
<ColorAnimation Storyboard.TargetName="ToggleColor"
Storyboard.TargetProperty="Color"
To="{StaticResource Selected}" Duration="0:0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard x:Name="ExitRadioButtonSelect">
<ColorAnimation Storyboard.TargetName="ToggleColor"
Storyboard.TargetProperty="Color"
To="{StaticResource Default}" Duration="0:0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
1条答案
按热度按时间ltskdhd11#
设置ExitActions颜色动画属性**-填充行为=“停止”-**
...