开发者

WPF Timer get value issue?

开发者 https://www.devze.com 2023-04-03 06:35 出处:网络
Like would like to check how to create a timer in WPF. Then, i would like to start the timer when button A is mouse down and stop the timer when the button A is moused up. After that i would like to f

Like would like to check how to create a timer in WPF. Then, i would like to start the timer when button A is mouse down and stop the timer when the button A is moused up. After that i would like to find out the value of the timer so i can u开发者_运维技巧se it on a if statement.

Any idea? Thank you very much!


Use System.Windows.Threading.DispatcherTimer, this way you know your timer is synced with you UI (assuming this is what you wanted), and you can use the Start and Stop method in your button's event handlers. You could use the tag to put the time at which you started the timer, and check that and the current time when you need your value, or make a getter that does that for you.

0

精彩评论

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