Hello,
We need to manage dynamically multiple InfoStrips in xamDataChart control (ideally in a ViewModel with the MVVM pattern )
Specifically, here are the blocking points encountered with ChartStripBehaviors :
1. Have the possibility to binding on the properties StartDateString, EndDateString from a source (ideally the DataContext of the main view)
2. Have the possibility to binding on the collection InfoStripCollection to manage multiple InfoStrips dynamically
Any suggestions would be appreciated
Best Regards,
Hello Anis,
Thank you for your email. I have been looking into the functionality that you have described and I have created custom Info Strip functionality for you, that allows generating the Info Strips by binding to a collection of your ViewModel. I have created a behavior with attached property that allows you to set info strip generator to all X axis of the XamDataChart (NumericXAxis, CategoryXAxis and CategoryDateTimeXAxis). The property is called CustomVerticalInfoStrip and accepts value from type CustomVerticalInfoStrip, which I have defined. The CustomVerticalInfoStrip contains several properties. In order to show the info strips you should set the ItemsSource property to a collection and I can suggest using an ObservableCollection<T> (of collection that implement INotifyCollectionChanged), so the CustomVerticalInfoStrip can detect changes in the collection. Also you should set the StripStartMemeberPath and StripEndMemeberPath to the names of the properties of the items source that determine the start and the end of each Info Strip. For the NumericXAxis, you can set the paths to double or int type properties, for the CategoryDateTimeXAxis, the properties should be from DateTime type and for the CategoryXAxis, you should use double of int properties and the strips will be aligned based on the indexes of the items of the source. For the CatecoryXAxis you can also use double values and for example, if you set star index to .5 the strip will start half way between the firs and the second item. I have created a sample application for you, that shows how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Hello Stefan,
Thanks for your Post.
Is it possible to use the view model as DataContext in Root Object , not as a static resource , because in our solution, the view is not responsible for the view model creation ?
Technically, the problem is that the attached property doesn’t have access to the DataContext of the object on which it is attached ! (in this case : ig:CategoryDateTimeXAxis)
Best Regards.
The only way to bind the InfoStrips is by using StaticResource, because they doesn't inherit from the VisualTree's DataContext.