Let TimeLineEvents be set from code


I need to set the events dynamically from my code. Loading from XML is not an option. I've not found a way to do that besides modifying the TimeLineTray class.
I'll provide my changes as a patch file. Most problematic part is that I had to disable VerifyNotInitialized. I'm not even sure why that's needed, but guess others may have problems now. Also you need to initialize the timelines (calling the new InitBands method) on the SizeChanged event once. As they need a size for calculation. Dirty but works so far fine in my project.
Other suggestions/improvements welcome ..

file attachments

Closed Mar 3, 2010 at 6:08 PM by andrewsyrov
Added TimelineReady event. You should be able to load events from this event handler.


andrewsyrov wrote Feb 18, 2010 at 5:24 PM

You can actually set the events dynamically, please take a look at SilverlightNews project there is a call to
Please let me know if it is not working for you.

marcmenghin wrote Feb 19, 2010 at 10:11 AM

ResetEvents is very good, didn't see that one. I must have overlooked it, would have saved me some work.

But still I need a way to modify the other values at runtime as well. As the data changes also start/end dates, scale changes. So with that method there is still the VerifyNotInitialized call in my way for most other things I need to update as the data updates.

Some kind of InitBands method like I added in my patch would be nice. So I can set the new max/min date, windowSize and ItemSourceType on the Timeline and then call a method that makes the setup on all bands. This maybe should also clear all current events. After that I could call the ResetEvents with my new events.

As a rough example to illustrate how it is supposed to works here: Imagine a Listbox that's filled with items that represent different Timeline streams. The user clicks on on item in the Listbox and the Timeline loads that data. The data can be only a few months of length or years. What we want is that the main band has the same scale all the time but the second one we have changes as the length of data changes.

In my case that Listbox would be huge, so everything is loaded on demand in the background from a server. All done in Silverlight. Basically I can't wait for the data to be there before I initialize and show the Timeline.

Im a little short on time right now but I'm going to upload an improved patch to take the ResetEvents into account. Should make it a little smaller.

andrewsyrov wrote Feb 19, 2010 at 5:21 PM

this is very a good comment. if you want to check in directly, please let me know and I will add you in the list of developers (just make sure the rest of the code samples work with your changes).

wrote Feb 27, 2010 at 3:20 PM

wrote Mar 3, 2010 at 6:08 PM

wrote Feb 21, 2013 at 11:09 PM

wrote May 16, 2013 at 10:49 AM