gpt4 book ai didi

c# - 多个 MultiDataTriggers 仅适用于最后一个

转载 作者:行者123 更新时间:2023-11-30 13:47:43 26 4
gpt4 key购买 nike

UserControl 中,我有一个 enum 类型的 DP(eGroupStyle 类型的 GroupStyle)和一个 DP bool 类型 (IsGrouped)。我需要在所有可能的条件下开始一些 Storyboard。但最后一个 MultiDataTrigger 只起作用。我哪里做错了?另外我想知道是否存在一种更简单的方法来考虑这些条件。 (检查一次 IsGrouped。)

C#:

enum eGroupStyle
{
GroupStyle1,
GroupStyle2,
∙∙∙,
GroupStyleN,
}

XAML:

<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding GroupStyle}" Value="GroupStyle1"/>
<Condition Binding="{Binding IsGrouped}" Value="False"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard_TurnToUnselectedStyle1}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding GroupStyle}" Value="GroupStyle1"/>
<Condition Binding="{Binding IsGrouped}" Value="True"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard_TurnToSelectedStyle1}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding GroupStyle}" Value="GroupStyle2"/>
<Condition Binding="{Binding IsGrouped}" Value="False"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard_TurnToUnselectedStyle2}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding GroupStyle}" Value="GroupStyle2"/>
<Condition Binding="{Binding IsGrouped}" Value="True"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard_TurnToSelectedStyle2}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
∙∙∙
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding GroupStyle}" Value="GroupStyleN"/>
<Condition Binding="{Binding IsGrouped}" Value="False"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard_TurnToUnselectedStyleN}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding GroupStyle}" Value="GroupStyleN"/>
<Condition Binding="{Binding IsGrouped}" Value="True"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard_TurnToSelectedStyleN}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>

最佳答案

我发现了!我需要在退出操作中删除之前的 Storyboard,如下所示。现在可以了:)

<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=GroupStyle}" Value="GroupStyle1"/>
<Condition Binding="{Binding Path=IsGrouped}" Value="False"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard x:Name="BeginStoryboard_TurnToUnselectedStyle1" Storyboard="{StaticResource Storyboard_TurnToUnselectedStyle1}"/>
</MultiDataTrigger.EnterActions>
<MultiDataTrigger.ExitActions>
<RemoveStoryboard BeginStoryboardName="BeginStoryboard_TurnToUnselectedStyle1"/>
</MultiDataTrigger.ExitActions>
</MultiDataTrigger>

关于c# - 多个 MultiDataTriggers 仅适用于最后一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15716607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com