Binding To Data

Jun 18, 2010 at 1:50 AM

Firstly, I'll describe our requirement.

Our system is based around Task management. Our customers maintain task data which has several dates involved. Start dates, estimated completion dates, deadline dates etc. We think this control is ideal for displaying this kind of data. But, what we need to display is live data, and our configuration experts need to be able to incorporate this control in to their user interface configuration using Xaml. So, what we need to be able to do is load the Task data from the database in to a Silverlight resource and then have the control bind to those records. We need to be able to configure which date columns the control binds to.

Would I be right in saying that the control does not currently do this? Would I be right in saying that in order to display Task data, we would have to export our task data to Xml, and format the data in to a set of events in the same way the Monet example works?

If my understanding is correct, are there any plans to allow the control to bind to a collection of objects and to be able to specify which columns to bind on?

If not, is there a way for the control to get at live Xml data? One option for us is to create an IValueConverter which converts a collection of our data in to an Xml string (formatted like the Monet example). The control could then bind to that string in the same way that it reads an Xml document from a Url.

Any thoughts on this?

 

Jun 18, 2010 at 5:36 PM

When you data updated/refreshed you can use ClearEvents/ResetEvents and provide updated collection of events to ResetEvents to show new data. Let me know if this is not want you need.

 

Jun 24, 2010 at 4:37 AM

Sorry, I don't really follow. With most Silverlight controls, there is an ItemsSource property which is IEnumerable. If I have a list of Tasks I should be able to do something like

var tasks= List<Task> = data.GetTasks();
Timeline.ItemsSource = tasks;

Is it possible to do something like this?



Or do we have to convert the tasks to Xml in the format in the samples?





Australia's #1 job site If It Exists, You'll Find it on SEEK
Jun 24, 2010 at 6:34 PM

Unfortunately, there is no ItemsSource property of the control now. ClearEvents/ResetEvents are the only option we have right now to change the list of events, but I believe you can use it for your case and successfully update the list of events, there are several examples in the solution which do this. If you believe, and I agree, ItemsSource is a better option please open a bug for me, I will resolve it in a week.

Jul 1, 2010 at 6:02 AM

If ItemsSource feature is added, it will help me a lot.

I am trying to use Timeline control with MVVM manner.

Since the Timeline does not have the Binding, it cannot update automatically and I had to use code behind for ClearEvent/ResetEvent execution.
(Of course it "can" by using additional Datatrigger or something but not directly.)

I am looking forward this feature.

Jul 1, 2010 at 7:29 AM
Yes, Youngjae, I agree. I have outlined my ideas here: http://timeline.codeplex.com/workitem/6344 Let's see what happens. I believe that if the Timeline control were to behave something like the way the Chart controls work, people would jump on this control. The control itself looks fantastic.
Jul 1, 2010 at 11:00 AM

Yaps, i use it with mvvm and feel the pain

i had a easy fix, my viewmodel knows when the collections of events, or visible events is changed , and i just fire a event , the view listen to that event , and every tiem it fires, it gets the evnets from it's datacontext(viewmodel) and clears he events and add's the new ones. This Solution dosen't break alot the mvvm since it's nto conditional code in the view codebehind.. it's only a clear and set new.. no logic here :)

 

but i woudl love to just bind a collection of Events and it worked...

i also think this control is the best on this kind no doubt.

Cheers

Rui

Jul 2, 2010 at 8:58 AM
Edited Jul 2, 2010 at 8:59 AM
ruiespinho wrote:

i had a easy fix, my viewmodel knows when the collections of events, or visible events is changed , and i just fire a event , the view listen to that event , and every tiem it fires, it gets the evnets from it's datacontext(viewmodel) and clears he events and add's the new ones. This Solution dosen't break alot the mvvm since it's nto conditional code in the view codebehind.. it's only a clear and set new.. no logic here :)

 

Refer to the ruispinho's comment, for all of you who want to combine this Timeline control with MVVM manner, please check the below link.

http://blog.flexforcefive.com/?p=206

This link introduces various way to make MVVM+codebehind trigger in order to update View automatically (can say half-manually).

IMHO, among them, I think RoutedEvent is the most understandable way to apply.

The advantage of CLR event is minimum codework but it is not somewhat WPF-like.

Jan 3, 2011 at 5:06 AM

Did an ItemsSource dp ever come to fruition here?  I'm thinking about using this control in my WPF app but it seems like requiring a URL to an XML file is too cumbersome, perhaps not feasible at all for this project.  After reading some of the posts about the coordinator of this project adding an ItemsSource property I was excited, but I don't see it available yet.  

 

Also curious if there'll ever be the ability to define how the data is used with data templates.  From what I have been able to find in documentation, we are stuck with the structure found here which is not at all useful to me unfortunately.

 

Thanks for any insight you can give.

Jan 3, 2011 at 6:04 AM

No ItemsSource property, please use ResetEvent, and pass collection of TimelineEvent there. Again, there are three methods to call it: to provide url, xml and collection of TimelineEvent objects, all through ResetEvent. If you are doing it from the code, do it in handler of TimelineReady event.

Apr 5, 2011 at 10:44 AM

Hi all,

Maybe in the future, can it be possible to set an event datasource that inherits from an ObservableCollection ? So it would avoid calling the ResetEvent each time the collection is modified, and, I think would avoid full Timeline recreation...

Thanks.