views:

87

answers:

2

Basically I'm wanting to insert a dynamic clock in my project. Right now I'm using the dateTime control which is fine but it's static. I need the clock to change digits with each second. In c# there is a Timer control that I would be able to use to make this dynamic clock possible. However, in Silverlight 4 I have not been able to locate any kind of Timer Control whatsoever to use in building this dynamic clock.

I didn't know if I was just looking in the wrong place or if it's right under my nose and I'm just missing it or what. Also, I assume using a timer control would be the best, however if there's a better approach to this please let me know that as well.

+5  A: 

DispatcherTimer Class

http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer(VS.95).aspx

Non non-UI use you also have the Timer Class

http://msdn.microsoft.com/en-us/library/system.threading.timer(v=VS.95).aspx

Jonathan Allen
You can use `System.Threading.Timer` for UI related updates, you just need to call the Dispatcher in the callback, since it happens on a background thread.
Nate Bross
Great links, exactly what I needed, thank you so much!
AmbiguousX
I ended up using a DispatcherTimer with its "tick" property being an event that essentially grabs the current system time each second, thus making the clock that appears on the screen dynamic. Thank you again for all your help!
AmbiguousX
+2  A: 

In case, you are interested in a working demo, you can try the solution from...

http://www.dotnetscraps.com/dotnetscraps/post/Silverlight-e28093-Create-a-binary-clock.aspx

Hope this helps!

Rahul Soni