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

How can I bind the visibility property of a data series through code?

4 Answers 98 Views
Chart
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 26 Apr 2011, 01:37 PM
Hi,

The SimpleFiltering example binds the visibility of a data series to a view model via XAML, eg.:
<telerik:DataSeries
    LegendLabel="EU-27">
    <telerik:DataSeries.Definition>
        <telerik:LineSeriesDefinition
            ItemLabelFormat="0.#"
            Visibility="{Binding Source={StaticResource ViewModel}, Path=SeriesEU27Visibility}" />
    </telerik:DataSeries.Definition>

How can I achieve the same functionality via code (I'm coding in Visual Basic)? I'm buidling my data series dynamically through code, however I haven't able to figure out how to bind the visibility property via code.

Kind regards,
Dave.

4 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 29 Apr 2011, 01:26 PM
Hi David,

Your question was answered in this forum post started by you.

Kind regards,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
David
Top achievements
Rank 2
answered on 29 Apr 2011, 01:36 PM
Hi Evgenia,

I'll ask my question in a different manner: How do the write the following XAML in code instead:
<telerik:DataSeries
    LegendLabel="EU-27"
    <telerik:DataSeries.Definition
        <telerik:LineSeriesDefinition
            Visibility="{Binding Source={StaticResource ViewModel}, Path=SeriesEU27Visibility}" /> 
    </telerik:DataSeries.Definition>
</telerik:DataSeries>
I can't figure out how to bind the visibility property of a data series in a chart to a property in a view model.

The other thread you referenced enquired about how I can save and retreive a property in the view model, however this thread asks how to bind a property in the chart control to a view model in code instead of XAML.

Kind regards,
Dave.
0
Accepted
Evgenia
Telerik team
answered on 04 May 2011, 02:49 PM
Hello David,

Now I get your question. Sorry for the misunderstanding. The SeriesDefinition.Visibility property is not a dependency property so you cannot use a binding expression to assign its value. Note that this cannot be improved at the moment as in Silverlight the binding target can be a DependencyProperty of a FrameworkElement only (not a generic DependencyObject) and the SeriesDefinition is a generic DependencyObject.

If you insist on creating the Simple Filtering demo in code-behind - refer to this forum post.

Regards,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
David
Top achievements
Rank 2
answered on 05 May 2011, 07:20 AM
Hi Evgenia,

Thanks for the clarification with the property and link to the previous forum post - I had not found it previously because it was in the Silverlight forum instead.

Kind regards,
Dave.
Tags
Chart
Asked by
David
Top achievements
Rank 2
Answers by
Evgenia
Telerik team
David
Top achievements
Rank 2
Share this question
or