Changing StripLine styles

5 posts, 1 answers
  1. Brennan
    Brennan avatar
    39 posts
    Member since:
    Sep 2010

    Posted 26 Jul 2011 Link to this post

    <Setter Property="Template2D">
                <Setter.Value>
                    <ControlTemplate TargetType="telerik:ChartArea">
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                Margin="{TemplateBinding Margin}"
                                Padding="{TemplateBinding Padding}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="auto" />
                                </Grid.RowDefinitions>
                                <telerik:AxisX2D x:Name="PART_AxisX"
                                                 Grid.Column="1"
                                                 Grid.Row="2"
                                                 Style="{TemplateBinding AxisXStyle}"
                                                 AxisLineStyle="{StaticResource YGridLineStyle}" />
                                <telerik:AxisY2D x:Name="PART_AxisY"
                                                 Grid.Column="0"
                                                 Grid.Row="1"
                                                 Style="{TemplateBinding AxisYStyle}"
                                                 AxisLineStyle="{StaticResource XGridLineStyle}" />
                                <telerik:AdditionalAxes2DContainer x:Name="PART_AdditionalHorizontalAxesPanel"
                                                                   Grid.Column="1"
                                                                   Grid.Row="0"
                                                                   StackOrientation="Vertical" />
                                <telerik:AdditionalAxes2DContainer x:Name="PART_AdditionalVerticalAxesPanel"
                                                                   Grid.Column="2"
                                                                   Grid.Row="1"
                                                                   StackOrientation="Horizontal"
                                                                   Visibility="Collapsed" />
                                <telerik:RadTransitionControl x:Name="PART_RadTransitionControl"
                                                              Grid.Column="1"
                                                              Grid.Row="1"
                                                              Style="{TemplateBinding TransitionControlStyle}">
                                    <telerik:ClipPanel x:Name="PART_PlotAreaPanel"
                                                       Style="{TemplateBinding PlotAreaStyle}">
                                        <telerik:DragZoomLayerControl x:Name="PART_DragZoomLayer"
                                                                      Style="{TemplateBinding DragZoomLayerControlStyle}">
                                            <ItemsPresenter />
                                        </telerik:DragZoomLayerControl>
                                        <telerik:HorizontalStripLines2D x:Name="PART_HorizontalStripLines" />
                                        <telerik:VerticalStripLines2D x:Name="PART_VerticalStripLines" />
                                        <telerik:AnnotationLayer x:Name="PART_AnnotationLayer"
                                                                 ItemsSource="{TemplateBinding Annotations}" />
                                        <telerik:VerticalMinorGridLines2D x:Name="PART_VerticalMinorGridLines" />
                                        <telerik:HorizontalMinorGridLines2D x:Name="PART_HorizontalMinorGridLines" />
                                        <telerik:HorizontalGridLines2D x:Name="PART_HorizontalGridLines" />
                                        <telerik:VerticalGridLines2D x:Name="PART_VerticalGridLines" />
                                        <telerik:AdditionalPlotAreaAxes2DContainer x:Name="PART_AdditionalPlotAreaHorizontalAxesPanel"
                                                                                   StackOrientation="Vertical" />
                                        <telerik:AdditionalPlotAreaAxes2DContainer x:Name="PART_AdditionalPlotAreaVerticalAxesPanel"
                                                                                   StackOrientation="Horizontal" />
     
                                        <telerik:PlotAreaAxisY2D x:Name="PART_PlotAreaAxisY"
                                                                 Style="{TemplateBinding PlotAreaAxisYStyle}" />
                                        <telerik:PlotAreaAxisX2D x:Name="PART_PlotAreaAxisX"
                                                                 Style="{TemplateBinding PlotAreaAxisXStyle}" />
                                        <telerik:LabelsPanel x:Name="PART_LabelsPanel" />
                                    </telerik:ClipPanel>
                                </telerik:RadTransitionControl>
                                <telerik:NoDataControl x:Name="PART_NoData"
                                                       Grid.ColumnSpan="3"
                                                       Grid.RowSpan="3"
                                                       Style="{TemplateBinding NoDataControlStyle}" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>

    Using this code I don't really understand how to set the style of the telerik:HorizontalStripLines2D... Where should the actual style for this be defined?
  2. Sia
    Admin
    Sia avatar
    667 posts

    Posted 27 Jul 2011 Link to this post

    Hello Brennan,

    In order to get your strip-lines styled you need to set the following custom style:
    <Style x:Key="CustomStripLines" TargetType="Rectangle">
        <Setter Property="Fill" Value="Red" />
    </Style>

    and apply it to the AxisY:
    this.Chart.DefaultView.ChartArea.AxisY.AxisStyles.StripLineStyle = this.Resources["CustomStripLines"] as Style;

    Regards,
    Sia
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WPF is Visual Studio 2017 Ready
  4. Brennan
    Brennan avatar
    39 posts
    Member since:
    Sep 2010

    Posted 27 Jul 2011 Link to this post

    Sorry, I should have been more specific in my question.  How would I apply the style to the X axis through XAML?  Thanks.
  5. Answer
    Sia
    Admin
    Sia avatar
    667 posts

    Posted 27 Jul 2011 Link to this post

    Hi Brennan,

    Here it is:
    <telerikChart:RadChart Name="Chart">
        <telerikChart:RadChart.DefaultView>
            <telerikCharting:ChartDefaultView>
                <telerikCharting:ChartDefaultView.ChartLegend>
                    <telerikCharting:ChartLegend x:Name="ChartLegend" />
                </telerikCharting:ChartDefaultView.ChartLegend>
                <telerikCharting:ChartDefaultView.ChartArea>
                    <telerikCharting:ChartArea Name="ChartArea" LegendName="ChartLegend">
                        <telerikCharting:ChartArea.AxisY>
                            <telerikCharting:AxisY>
                                <telerikCharting:AxisY.AxisStyles>
                                    <telerikCharting:AxisStyles StripLineStyle="{StaticResource CustomStripLines}" />
                                </telerikCharting:AxisY.AxisStyles>
                            </telerikCharting:AxisY>
                        </telerikCharting:ChartArea.AxisY>
                        <telerikCharting:ChartArea.DataSeries>
                            <telerikCharting:DataSeries>
                                <telerikCharting:DataSeries.Definition>
                                    <telerikCharting:BarSeriesDefinition  />
                                </telerikCharting:DataSeries.Definition>
                                <telerikCharting:DataPoint YValue="10" />
                                <telerikCharting:DataPoint YValue="10" />
                            </telerikCharting:DataSeries>
                        </telerikCharting:ChartArea.DataSeries>
                    </telerikCharting:ChartArea>
                </telerikCharting:ChartDefaultView.ChartArea>
            </telerikCharting:ChartDefaultView>
        </telerikChart:RadChart.DefaultView>
    </telerikChart:RadChart>


    Best wishes,
    Sia
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. Brennan
    Brennan avatar
    39 posts
    Member since:
    Sep 2010

    Posted 27 Jul 2011 Link to this post

    Thank you so much!
Back to Top
UI for WPF is Visual Studio 2017 Ready