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

CategoricalSeriesDescriptor dynamic LineStroke color

2 Answers 121 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Jerome
Top achievements
Rank 1
Jerome asked on 20 Jun 2013, 10:53 PM
                        <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 Answers, 1 is accepted

Sort by
0
Jerome
Top achievements
Rank 1
answered on 21 Jun 2013, 04:23 PM
                                <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.
0
Petar Kirov
Telerik team
answered on 25 Jun 2013, 02:22 PM
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.

Tags
ChartView
Asked by
Jerome
Top achievements
Rank 1
Answers by
Jerome
Top achievements
Rank 1
Petar Kirov
Telerik team
Share this question
or