CategoricalSeriesDescriptor dynamic LineStroke color

3 posts, 0 answers
  1. Jerome
    Jerome avatar
    87 posts
    Member since:
    Aug 2010

    Posted 20 Jun 2013 Link to this post

                            <telerik:CategoricalSeriesDescriptor
                                ItemsSourcePath="Remitted"
                                CategoryPath="Date"
                                ValuePath="Value">
                                <telerik:CategoricalSeriesDescriptor.Style>
                                    <Style
                                        TargetType="telerik:LineSeries">
                                    </Style>
                                </telerik:CategoricalSeriesDescriptor.Style>
                            </telerik:CategoricalSeriesDescriptor>

    I would like to be able to bind the LineSeries Stroke property to use a dynamic Color. Adding a Setter into here to set the Stroke property seems to work, but I can't seem to reference anything useful in the DataContext. I need a way to reference the item that created the series.
  2. Jerome
    Jerome avatar
    87 posts
    Member since:
    Aug 2010

    Posted 21 Jun 2013 Link to this post

                                    <Style
                                        TargetType="telerik:LineSeries">
                                        <Style.Setters>
                                            <Setter
                                                Property="Stroke">
                                                <Setter.Value>
                                                    <SolidColorBrush
                                                        Color="{Binding Color}" />
                                                </Setter.Value>
                                            </Setter>
                                        </Style.Setters>
                                    </Style>


    So, I tried this. It results in the series line vanishing. There's no errors popping up about the binding, which I would expect if the Color property could not be found.
  3. DevCraft banner
  4. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 25 Jun 2013 Link to this post

    Hi Jerome,

    You are on the right track, however there's one detail that is preventing this from working - you have to bind the Stroke property of the ChartSeries directly to a Brush property, because the SolidColorBrush.Color property is not a DependencyProperty you can not bind it.

    To give you a jump start I have attached a sample project.

    I hope this helps.

    Regards,
    Petar Kirov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top