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.
精彩评论