RadChart PlotArea Backgroud Change

2 posts, 0 answers
  1. Vijay
    Vijay avatar
    16 posts
    Member since:
    Apr 2011

    Posted 27 Oct 2011 Link to this post

    Hi,

    I am trying to update chart plotarea style at the run time like this.
    http://www.telerik.com/help/silverlight/radchart-styling-and-appearance-styling-plot-area.html

    from code behind MVVM like this .
    <Style x:Key="ClipPanelStyle"
           TargetType="telerik:ClipPanel">
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="1,0" StartPoint="0,1" Opacity="0.5" SpreadMethod="Pad">
                            <GradientStop Color="Orange" Offset="0" />
                            <GradientStop Color="Black" Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>
    I implemented Above code in code behind like below code.
    var brush = new LinearGradientBrush { StartPoint = new Point(0, 1), EndPoint = new Point(1, 0) };
                var stop1 = new GradientStop { Color = Colors.Purple, Offset = 0.0 };
                brush.GradientStops.Add(stop1);
                var stop2 = new GradientStop { Color = Colors.Yellow, Offset = 1.0 };
                brush.GradientStops.Add(stop2);
                _radChart.DefaultView.ChartArea.PlotAreaStyle.Setters.Add(new Setter() { Property = ClipPanel.BackgroundProperty, Value = brush });

    But when i am trying this i am getting attached error it actually worked for some time but i started getting this error all of a sudden
    Can some one help me to put me in right direction .


    Thanks!
    Vijay



  2. Sia
    Admin
    Sia avatar
    745 posts

    Posted 01 Nov 2011 Link to this post

    Hi Vijay,

    Please try setting it as follows:
    var brush = new LinearGradientBrush { StartPoint = new Point(0, 1), EndPoint = new Point(1, 0) };
    var stop1 = new GradientStop { Color = Colors.Purple, Offset = 0.0 };
    brush.GradientStops.Add(stop1);
    var stop2 = new GradientStop { Color = Colors.Yellow, Offset = 1.0 };
    brush.GradientStops.Add(stop2);
     
    Style style = new Style { TargetType = typeof(ClipPanel) };
    style.Setters.Add(new Setter() { Property = ClipPanel.BackgroundProperty, Value = brush });
    RadChart1.DefaultView.ChartArea.PlotAreaStyle = style;

    Regards,
    Sia
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top