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

bind bar series definition visibility programmatically

1 Answer 102 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Nemanja
Top achievements
Rank 1
Nemanja asked on 05 Oct 2011, 06:11 PM
I'm having trouble adding a binding to the visibility property of the series definition object programmatically. the binding works fine in xaml, but the object doesn't seem to have a SetBinding() function available to it, only a SetValue() - which doesn't set binding, only the value..

is there another way to do this?

i define a series mapping in XAML but allow users to change the chart type which clears the binding. below is the XAML definition:

<rad:SeriesMapping.SeriesDefinition>
                            <rad:BarSeriesDefinition ShowItemLabels="True" ShowItemToolTips="True" ItemLabelFormat="#ProposedSalesQty{#,###,###,##0}"
                                                     ItemToolTipFormat="#AttributeName, #ProposedSalesQty{#,###,###,##0}" Visibility="{Binding ProposedSalesQtySeriesVisibility}">
                                <rad:BarSeriesDefinition.Appearance>
                                    <rad:SeriesAppearanceSettings Fill="SkyBlue" />
                                </rad:BarSeriesDefinition.Appearance>
                            </rad:BarSeriesDefinition>
                        </rad:SeriesMapping.SeriesDefinition>


And in the C# code-behind i attempt to change the value this way:

((LineSeriesDefinition)MixChart.SeriesMappings[0].SeriesDefinition).SetBinding(
                        LineSeriesDefinition.VisibilityProperty, new Binding("ProposedSalesQtySeriesVisibility"));

there is no SetBinding() function so i'm not sure how i can add the binding alternatively? it can be done perfectly in XAML but not sure about code behind...

Thanks,
Nemanja

1 Answer, 1 is accepted

Sort by
0
Nemanja
Top achievements
Rank 1
answered on 06 Oct 2011, 02:45 PM
found a solution on the siliverlight forums...

http://www.telerik.com/community/forums/silverlight/chart/binding-seriesdefinition-in-code-behind.aspx

for visibility, it's just a matter of using the visibilityproperty instead of the one in there...

thanks.
Tags
Chart
Asked by
Nemanja
Top achievements
Rank 1
Answers by
Nemanja
Top achievements
Rank 1
Share this question
or