Start a VisualState transition from XAML

蓝咒 提交于 2020-01-04 04:20:09

问题


In a user control (or whatever), we all know that the VisualStateManger can be used in code to start a transition, or animation, like so:

    if (target.IsLocked)
    {
      VisualStateManager.GoToState(this, "Locked", true);
    }
    else if (target.IsBroken)
    {
      VisualStateManager.GoToState(this, "Broken", true);
    }
    else
    {
      VisualStateManager.GoToState(this, "Normal", true);
    }

However, there seems to be very little or no information about triggering these type of animations from XAML. Could a DataTemplate or Trigger be defined that could provide behaviour equivalent to the code listed above?


回答1:


Using Interativity from the Blend SDK i am sure you could do something like this.

Edit: It contains a GoToStateAction specifically for this.

There are other libraries like Markup Programming which might be able to do something similar. It also demonstrates that you can do pretty much anything in XAML if you want to.




回答2:


Use data trigger with gotstateaction behavior



来源:https://stackoverflow.com/questions/6862332/start-a-visualstate-transition-from-xaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!