创建彩色闪烁效果 [英] Create colour flashing effect

查看:50
本文介绍了创建彩色闪烁效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我正在创建一个控制器,它会计算10分钟的时间。当此控件达到3分钟时,我希望它闪烁绿色几秒钟然后继续其正常状态。当计时器达到零分钟时,它应该连续闪烁
a绿色,直到用户选择一个选项做什么。


我如何使用可视状态管理器来创建效果,它将在控件的正常颜色和绿色之间交替以产生闪烁效果?


我对VisualStateManager很新,所以任何帮助都可以。


谢谢,

解决方案

作为基本概要:


1。创建一个新的可视状态组,将其命名为任何您喜欢的名称,例如"CounterStates"


2。在其中创建2个状态,1将是基本/原始状态,而另一个是绿色状态,将它们命名为"base"状态。和"绿色"


3。选择绿色状态,在美工板上进行所需的更改(将背景更改为绿色)


4。现在,在控件到达目标时间时触发的代码中,可以调用VisualStateManager.GoToState(this,"green",true);,然后调用VisualStateManager.GoToState(this,"base",true)来获取在
适当的时间回到非绿色。


这个方法的关键是你必须创建一个名为base的状态,因为没有"返回基本状态" ;内置的方法或命令。


还有其他几种方法可以完成你想要做的事情,包括使用故事板,但这可能是最简单的。


Hi there,

I am creating a control which will count down time from, say, 10minutes. When this control reaches 3 minutes I want it to flash a green colour for a few seconds and then continue with its normal state. When the timer reaches zero minutes, it should flash a green colour continually until the user will select an option what to do.

How would I go about with the visual state manager to create the effect where it will alternate between the control's normal colour and a green colour to create a flashing effect?

I'm pretty new to the VisualStateManager, so any help will do.

Thank you,

解决方案

As a basic outline:

1. Create a new visual state group, name it anything you like, such as "CounterStates"

2. Create 2 states within, 1 will be the base/original state, and the other the green state, name them something like "base" and "green"

3. Select the green state, make the changes you want on the artboard (change the background to green)

4. Now, in your code that triggers when the control reaches the targetted times, you can call VisualStateManager.GoToState(this, "green", true);, and then VisualStateManager.GoToState(this, "base", true) to get back to non green at the appropriate time.

The key with this method is you have to create a state called base, because there is no "go back to base state" method or command built in.

There are several other ways you could accomplish what you are trying to do, including using storyboards, but this is probably the simplest.


这篇关于创建彩色闪烁效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆