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

Styling a chart's Y-Axis striplines, etc

1 Answer 74 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Adam Petaccia
Top achievements
Rank 1
Adam Petaccia asked on 11 Jun 2010, 04:42 PM
I'm trying to style my Y-Axis striplines (eventually to be bound), but I can't seem to do so correctly. Declaritvely, I can set a single chart's ChartArea.AxisY.StripLinesVisibility to Collapsed, but everything I have tried makes it seem as if these guys were impervious to styles. So basically: how to:
  * Declare the style correctly in XAML
  * Set the style correctly in C#, at the time of Chart creation (I must do it like this, as the charts are created at run time)

Currently, I have in my XAML:
<UserControl.Resources> 
    <Style TargetType="Rectangle" x:Key="StripLinesYStyle
      <Setter Property="Visibility" Value="Collapsed" /> 
    </Style> 
</UserControl.Resources> 

and where I'm creating the chart I have

var stripLineStyle = this.Resources["StripLinesYStyle"as Style; 
myChart.DefaultView.ChartArea.AxisY.AxisStyles.StripLineStyle = stripLineStyle; 



1 Answer, 1 is accepted

Sort by
0
Accepted
Sia
Telerik team
answered on 16 Jun 2010, 02:24 PM
Hello Adam Petaccia,

You need to have the following styles in the Resources of your application:
<Style x:Key="HorizontalStripLineStyle" TargetType="Rectangle" >
     <Setter Property="Fill" Value="Red" />
</Style>
<Style x:Key="VerticalStripLineStyle" TargetType="Rectangle" >
     <Setter Property="Fill" Value="Blue" />
</Style>

and apply them in your code-behind by having:
RadChart1.DefaultView.ChartArea.AxisX.AxisStyles.AlternateStripLineStyle = this.Resources["HorizontalStripLineStyle"] as Style;
RadChart1.DefaultView.ChartArea.AxisY.AxisStyles.AlternateStripLineStyle = this.Resources["VerticalStripLineStyle"] as Style;

As I see the only difference is that you are trying to change the StripLineStyle not the AtlernateStripLineStyle. By default the second one is set and you cannot overwrite it by setting the first one.

If you still experience problems, just let us know.

Greetings,
Sia
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.
Tags
Chart
Asked by
Adam Petaccia
Top achievements
Rank 1
Answers by
Sia
Telerik team
Share this question
or