bind bar series definition visibility programmatically

2 posts, 0 answers
  1. Nemanja
    Nemanja avatar
    27 posts
    Member since:
    Mar 2011

    Posted 05 Oct 2011 Link to this post

    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
  2. Nemanja
    Nemanja avatar
    27 posts
    Member since:
    Mar 2011

    Posted 06 Oct 2011 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top