在用户控件(或其他控件)中,我们都知道 VisualStateManger 可以在代码中用于启动过渡或动画,如下所示:
if (target.IsLocked)
{
VisualStateManager.GoToState(this, "Locked", true);
}
else if (target.IsBroken)
{
VisualStateManager.GoToState(this, "Broken", true);
}
else
{
VisualStateManager.GoToState(this, "Normal", true);
}
但是,关于从 XAML 触发这些类型的动画的信息似乎很少或没有。是否可以定义一个 DataTemplate 或 Trigger 来提供与上面列出的代码等效的行为?
最佳答案
使用具有 gotstateaction 行为的数据触发器
关于c# - 从 XAML 开始 VisualState 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6862332/