我试图制作一个MultiTrigger条件,但我需要根据TextBlock标签更改此条件,如果Tag = 0运行第一个触发器,而Tag = 1则运行另一个触发器。但是在我的代码中,如果标签= 0的触发条件运行,此后标签变为1,则另一个触发器不会运行。
我正在使用此代码:
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Background" Value="#FF333333"/>
<Setter Property="Foreground" Value="#FFBEBEBE"/>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Tag" Value="0"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color" To="White" Duration="0:0:0.300" />
<ColorAnimation Storyboard.TargetProperty="Foreground.Color" To="Black" Duration="0:0:0.300" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color" To="#FFF0F2F3" Duration="0:0:0.300" />
<ColorAnimation Storyboard.TargetProperty="Foreground.Color" To="Black" Duration="0:0:0.300" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Tag" Value="1"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color" To="#222222" Duration="0:0:0.300" />
<ColorAnimation Storyboard.TargetProperty="Foreground.Color" To="#FFFFFF" Duration="0:0:0.300" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color" To="#FF333333" Duration="0:0:0.300" />
<ColorAnimation Storyboard.TargetProperty="Foreground.Color" To="#FFBEBEBE" Duration="0:0:0.300" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
</Style.Triggers>
</Style>
有人知道这段代码有什么问题吗?或许它可能。