Line loosing dashed style after rebind

3 posts, 0 answers
  1. Ola
    Ola avatar
    5 posts
    Member since:
    Aug 2011

    Posted 24 Jan 2012 Link to this post


    I have a Chart with a couple of series. I want one of the series to display a dashed line. I also have a data grid, when I select a product from the grid the chart will display the data of the selected product.

    First I tried to define a style and set it to the Serie in XAML:

            <Style x:Name="ForecastRedStyle" TargetType="charting:SelfDrawingSeries">
                <Setter Property="BorderLineStyle">
                        <Style TargetType="Path">
                            <Setter Property="StrokeDashArray" Value="1"/>
                            <Setter Property="Stroke" Value="#FF90362E" />
                            <Setter Property="StrokeThickness" Value="2" />


    <telerik:SeriesMapping LegendLabel="Forecast 8-12">
                                                <telerik:LineSeriesDefinition ShowItemLabels="False" ShowItemToolTips="True"
                                                                        ShowPointMarks="True" SeriesStyle="{StaticResource ForecastRedStyle}" />
                                                <telerik:ItemMapping FieldName="StartDate"
                                                            DataPointMember="XValue" />
                                                <telerik:ItemMapping FieldName="ForecastRed"
                                                            DataPointMember="YValue" />


    Result: It worked the first time the chart was displayed but as soon as I selected another product the style did not display anymore (the line was not dashed).

    Second try: I put this in code behind.

            private void gridProducts_SelectionChanged(object sender, SelectionChangeEventArgs e)
                Style yellowStyle = new Style(typeof(Path));
                yellowStyle.Setters.Add(new Setter(Shape.StrokeDashArrayProperty, "5,2"));
                yellowStyle.Setters.Add(new Setter(Shape.StrokeProperty, "#FFC28F12"));
                yellowStyle.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2));

                Style yellowLineStyle = new Style(typeof(Telerik.Windows.Controls.Charting.LineSeries));
                yellowLineStyle.Setters.Add(new Setter(LineSeries.BorderLineStyleProperty, yellowStyle));

                Style redStyle = new Style(typeof(Path));
                redStyle.Setters.Add(new Setter(Shape.StrokeDashArrayProperty, "1"));
                redStyle.Setters.Add(new Setter(Shape.StrokeProperty, "#FF90362E"));
                redStyle.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2));

                Style redLineStyle = new Style(typeof(Telerik.Windows.Controls.Charting.LineSeries));
                redLineStyle.Setters.Add(new Setter(LineSeries.BorderLineStyleProperty, redStyle));

                radChart.SeriesMappings[2].SeriesDefinition = new LineSeriesDefinition();
                radChart.SeriesMappings[3].SeriesDefinition = new LineSeriesDefinition();

                radChart.SeriesMappings[2].SeriesDefinition = new LineSeriesDefinition() { SeriesStyle = yellowLineStyle, ShowItemLabels = false, ShowPointMarks = true, ShowItemToolTips = true };
                radChart.SeriesMappings[3].SeriesDefinition = new LineSeriesDefinition() { SeriesStyle = redLineStyle, ShowItemLabels = false, ShowPointMarks = true, ShowItemToolTips = true };

    Result: It works first time the chart is displayed. But it does not work when I select another product first time. But then it works every time I select another product after that.

    Does anyone know what is going on here?


  2. Sia
    Sia avatar
    692 posts

    Posted 27 Jan 2012 Link to this post

    Hello Ola,

    In my opinion you hit a limitation of the Silverlight framework. Please check this forum thread where a solution is suggested and let us know how it works on your end.

    Kind regards,
    the Telerik team

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

  3. Ola
    Ola avatar
    5 posts
    Member since:
    Aug 2011

    Posted 27 Jan 2012 Link to this post

    The solution using ZoomScrollSettingsPropertyChanged worked!

    Thank you!!!

Back to Top