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

Template Selector

4 Answers 66 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Joachim
Top achievements
Rank 1
Joachim asked on 04 Aug 2011, 03:46 PM
Hello,

I have a calculation which can result in different types of charts.
I know which kind of chart data is being calculated.

I am using the MVVM pattern so the charts are pre defined in xaml
and i only have to provide them data.

Is there a way to load a different  template for different calculation responses.

A sort of data template selector, but I noticed RadChart doesnt support that(yet).

4 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 09 Aug 2011, 02:41 PM
Hello Joachim,

Have you considered binding the SeriesMapping.SeriesDefinition property to a property value in your ViewModel? In this way you will be able to control the projected series type from the ViewModel itself.


Greetings,
Bart.
0
Joachim
Top achievements
Rank 1
answered on 09 Aug 2011, 02:51 PM
I think that would mean I have to put a reference to telerik in our viewmodel. If there is no other way I will consider that.
At the moment i have solved it by making different views for different types of charts, which means a lot of duplicate code which essentially is almost the same.

So if there's a better way please let me know.

Also could you give me an example on how to do that?
0
Joachim
Top achievements
Rank 1
answered on 10 Aug 2011, 08:29 AM
Ok, i solved the reference issue through a converter. Now i get different seiresdefinition depending on results.
Not I have the problem that I had ShowItemLabels bound to the value of a checkbox, but ShowItemsLabels is
a property of the seriesdefinition which is now defined in my Converter. How can I still bind my dependency property
to ShowItemLabels?
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 12 Aug 2011, 03:41 PM
Hello Joachim,

You can probably use "reversed" two-way element name binding on the Chechbox.IsChecked property like this:
<CheckBox IsChecked="{Binding ElementName=RadChart1, Path=SeriesMappings[0].SeriesDefinition.ShowItemLabels, Mode=TwoWay}" Content="Show Labels" />


Greetings,
Bart.
Tags
Chart
Asked by
Joachim
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Joachim
Top achievements
Rank 1
Share this question
or