This is a migrated thread and some comments may be shown as answers.

Updating databound styles and templates

5 Answers 57 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 30 Dec 2009, 12:54 AM

In the article below:

http://geekswithblogs.net/tkokke/archive/2009/04/01/creating-binding-and-styling-a-bubble-chart.aspx

 

He shows how one can use the BubbleDataTemplate to change the markers on a bubble chart. What I am looking at figuring out how to do is to use a MVVM model to have the template come via databinding from the ViewModel (actually that is easy). But what if you want to update the template. (yes, this is for the Silverlight Toolkit, but I think similar things can be done here).

Given that it is Databound the property change should propagate to the BubbleDataTemplate. But this is not like binding an ObservableCollection to the ItemSource. There the event is automatically handled for you, and the chart will update with the new data being pushed from the ViewModel.

 

What about also pushing the new style for the Data. Or for that matter any other Chart style element that is being data driven from the ViewModel?

 

I would not cry if I need some code behind in View class to refresh the display. But what do I do and how do I detect it?


5 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 04 Jan 2010, 03:54 PM
Hi Dr.YSG,

We indeed have developed some examples using the MVVM approach and it is natively supported.
You can check our example here. As well as documentation about this feature.

If you run into a more specific scenario do let us know and we will do our best to assist.

Kind regards,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dr.YSG
Top achievements
Rank 2
answered on 04 Jan 2010, 04:14 PM
Excellent.

Now, since barSeries.ItemStyle is a dependency property. Is it not possble to have it bound to the VM object? Then the VM object could update the property and a new form of BarStyle would be dynamically displayed?

Right now, you are binding the GradeColor and updating it in the VM. And firing a property changed message when the grade changes.
I think that is great.

What I would like to do is something a little more dramatic. Not just change the color of the bar, but really have a different template depending on how the data changes. So I would have the barSeries.Item style bound to a property in the VM, and then when the data changes, I would like to fire a property changed event (should this be for the individual person?) so that the style is changed for that person?

The truth is that I don't need indvidual templates for each "person" but that I will have different types of collections of persons, and I what all of them to change at once.

The key here is that the Fill property of the PART_DefinitionGeometry element name is bound to the DataItem.GradeColor

XAML Copy Code
<Rectangle x:Name="PART_DefiningGeometry"
      
.......
      
Fill="{Binding DataItem.GradeColor}" />




0
Vladimir Milev
Telerik team
answered on 07 Jan 2010, 03:32 PM
Hello Dr.YSG,

You can bind other appearance related properties, however, currently you may not have different templates for different VMs. Being able to change just about anything in the template eliminates the need for that or at least so we though. Do you have a scenario where this limitation is stopping you?

Thanks for your feedback.

Best wishes,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dr.YSG
Top achievements
Rank 2
answered on 07 Jan 2010, 05:16 PM
I am using a MVVM paradigm for programming.

So when the ViewModel changes the data, I want to update both the ItemSource  and the ItemStyle from the ViewModel and have the View now display a different values (from the ItemSource) and a different style (from the ItemStyle) that was bound.

So yes, there would be different templates, but the templates would be under the control of the ViewModel and swapped in and out depending on what the values of the data is in the ViewModel.

Make sense?


0
Vladimir Milev
Telerik team
answered on 12 Jan 2010, 03:57 PM
Hi Dr.YSG,

Thanks for the input. We will definitely take this into consideration when planning ahead our product development. Your points have been updated.

Kind regards,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Vladimir Milev
Telerik team
Dr.YSG
Top achievements
Rank 2
Share this question
or