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

RadChart PlotArea Backgroud Change

1 Answer 73 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 27 Oct 2011, 10:57 PM
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



1 Answer, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 01 Nov 2011, 04:43 PM
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 >>

Tags
Chart
Asked by
Vijay
Top achievements
Rank 1
Answers by
Sia
Telerik team
Share this question
or