开发者

Start a VisualState transition from XAML

开发者 https://www.devze.com 2023-03-23 19:49 出处:网络
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:

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 littl开发者_JAVA百科e 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?


Use data trigger with gotstateaction behavior


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号