c# - 从 XAML 开始 VisualState 转换

标签 c# wpf xaml visualstatemanager

在用户控件(或其他控件)中,我们都知道 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/

相关文章:

c# - 如何避免 WPF 中的抗锯齿?

c# - 从 MVVM 中的 DataGrid 或 ListBox 绑定(bind)到 SelectedItems

c# - 发生类型为 'System.InvalidCastException' 的第一次机会异常

c# - 无法使用 Autofac 解析 NameValueCollection

c# - 在执行数据库搜索时使用 OrderBy 查询对不带第一个字符的数字进行排序

c# - 尝试在 C# WPF 应用程序中捕获

c# - richtextbox 到字符串

c# - ASP.NET 网络 API : any downsides to asynchronous operations?

c# - VS 2017 .Net Core 2.0 控制台应用程序发布失败

c# - Caliburn Micro Guard Methods 不评估属性变化