Hi,
I took a look at your demo for simple filtering in a RadChart and I wanted to adapt this code to my needs.
In the xaml code of Example.xaml there is this line
I guess it means that for each SeriesDefinition, you bind the Visibility attribute to a SeriesVisibility.
My problem is that I would like to do the same in code-behind because I create dynamically the SeriesDefinition (in code-behind as well).
In fact, what I wanted to do is first, to create a dictionnary<String,SeriesVisbility>.
Each time I create a SeriesMapping and the corresponding SeriesDefinition, I would add to the dictionnary an item with the legendLabel attribute (unique in my case) as a key and a SeriesVisibility as the value.
I would then bind in code-behind this SeriesVisibility to the attribute Visibility of the SeriesDefinition.
Finally, in the ChangeSeriesVisibility(object parameter) method of ExampleViewModel, I would directly access to the SeriesVisibility thanks to the legendLabel (which is the key of my dictionnary) and change it between collapsed and visible. Then, the corresponding series will be hidden or visible because it was "bound" to the changed SeriesVisibility.
I'm a beginner, so is there a solution to do something like that? This code is of course wrong...
Thanks for everything.
I took a look at your demo for simple filtering in a RadChart and I wanted to adapt this code to my needs.
In the xaml code of Example.xaml there is this line
<
telerik:LineSeriesDefinition
ItemLabelFormat
=
"0.#"
Visibility="{Binding Source={StaticResource ViewModel},
Path
=
SeriesEU27Visibility
}" />
I guess it means that for each SeriesDefinition, you bind the Visibility attribute to a SeriesVisibility.
My problem is that I would like to do the same in code-behind because I create dynamically the SeriesDefinition (in code-behind as well).
In fact, what I wanted to do is first, to create a dictionnary<String,SeriesVisbility>.
Each time I create a SeriesMapping and the corresponding SeriesDefinition, I would add to the dictionnary an item with the legendLabel attribute (unique in my case) as a key and a SeriesVisibility as the value.
I would then bind in code-behind this SeriesVisibility to the attribute Visibility of the SeriesDefinition.
Finally, in the ChangeSeriesVisibility(object parameter) method of ExampleViewModel, I would directly access to the SeriesVisibility thanks to the legendLabel (which is the key of my dictionnary) and change it between collapsed and visible. Then, the corresponding series will be hidden or visible because it was "bound" to the changed SeriesVisibility.
I'm a beginner, so is there a solution to do something like that? This code is of course wrong...
StackedBarSeriesDefinition sd = new StackedBarSeriesDefinition();
SeriesVisibility sv = new SeriesVisibility();
sv = SeriesVisibility.Visible;
Binding bnd = new Binding();
bnd.Source = sv;
sd.SetBinding(StackedBarSeriesDefinition.VisibilityProperty, sv);
Thanks for everything.