基于计时器事件在 Blend 4 VisualStateManager 中旋转状态?

发布于 2024-09-08 06:27:21 字数 323 浏览 3 评论 0原文

我正在 Blend 中构建一个 Silverlight 4 UserControl,它具有三个 VisualStates。

我想让状态在延迟几秒钟后从第一个状态更改为第二个状态,再过几秒后从第二个状态更改为第三个状态,在另一个延迟后从第三个状态更改为第一个状态,然后继续像这样旋转。

本质上,这是一个非常原始的“广告旋转器”,使用一些静态图像来构建我正在构建的原型。

使用 Blend 可以做到这一点吗?如果是这样,怎么办?我可以使用 TimerTriggers 和 ActivateStateAction 行为来创建第一次完整旋转,但我不确定如何重置计时器,或者其他方法是否会更好。

I'm building a Silverlight 4 UserControl in Blend which has three VisualStates.

I would like to have the states change from the first to the second state after a delay of a few seconds, second to third after a few more seconds, third to first after another delay, and continue rotating like that.

Essentially, this is a very primitive "ad rotator", using some static images for a prototype I'm building.

Is it possible to do this using Blend? If so, how? I'm able to use TimerTriggers and ActivateStateAction behaviors to create the first full rotation, but I'm not sure how to reset the timers, or whether another approach will work better.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉城凉梦凉人心 2024-09-15 06:27:21
  1. 使用 x:Name 标签命名控件;我将我的命名为“ControlName”
  2. 声明一个 TimerTrigger:

    
        
    
    
  3. 在后面的代码中使用您的状态来实现此代码。是的。背后的代码。

    公共子 NextState()

     选择 Case Me.RotateImageStates.CurrentState.Name
            案例“run1”
                VisualStateManager.GoToState(我,“run2”,True)
            案例“run2”
                VisualStateManager.GoToState(我,“run3”,True)
            案例“run3”
                VisualStateManager.GoToState(我,“run1”,True)
            其他情况
                VisualStateManager.GoToState(我,“run1”,True)
        结束选择   
    

    End Sub

  4. ...?

  5. 利润!

使用 x:Name="SomeName" 命名控件

  1. Name the control with an x:Name label; I named mine "ControlName"
  2. Declare a TimerTrigger:

    <ei:TimerTrigger MillisecondsPerTick="3000">
        <ei:CallMethodAction MethodName="NextState" TargetObject="{Binding ElementName=ControlName}"/>
    </ei:TimerTrigger>
    
  3. Implement this code with your states in the code behind. Yes. The Code Behind.

    Public Sub NextState()

        Select Case Me.RotateImageStates.CurrentState.Name
            Case "run1"
                VisualStateManager.GoToState(Me, "run2", True)
            Case "run2"
                VisualStateManager.GoToState(Me, "run3", True)
            Case "run3"
                VisualStateManager.GoToState(Me, "run1", True)
            Case Else
                VisualStateManager.GoToState(Me, "run1", True)
        End Select   
    

    End Sub

  4. ...?

  5. Profit!

Name the control with an x:Name="SomeName"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文