title | description | type | page_title | slug | position | tags | ticketid | res_type |
---|---|---|---|---|---|---|---|---|
How to Bind ValueBinding Property of a Series by Using CategoricalSeriesDescriptor |
This article demonstrates how to bind the ValueBinding property of a series using a CategoricalSeriesDescriptor. |
how-to |
How to DataBind ValuePath of CategoricalSeriesDescriptor |
kb-chartview-bind-valuebinding-with-categoricalseriesdescriptor |
0 |
ValuePath, IValueConverter, CategoricalSeriesDescriptor, ValueBinding |
1431542 |
kb |
Product Version | 2019.3.917 |
Product | RadChartView for WPF |
How to DataBind ValuePath of CategoricalSeriesDescriptor.
As the ValuePath property cannot be data bound what we need do instead is use the Style property of the descriptor to bind the ValueBinding property of the series.
-
In the code-behind we need to create a StringToValuePathConverter like so:
{{region kb-chartview-bind-valuebinding-with-categoricalseriesdescriptor-0}} public class StringToValuePathConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var valuePath = value.ToString(); return new PropertyNameDataPointBinding(valuePath); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); }
} {{endregion}}
-
In XAML use a ValueBinding property of a series with an IValueConverter. To do that use the Style property of the CategoricalSeriesDescriptor like so:
{{region kb-chartview-bind-valuebinding-with-categoricalseriesdescriptor-1}} telerik:ChartSeriesProvider.SeriesDescriptors <telerik:CategoricalSeriesDescriptor x:Name="seriesDescriptor" CategoryPath="ArchiveTime"
ItemsSourcePath="ChartItems"> telerik:CategoricalSeriesDescriptor.Style <Style TargetType="telerik:BarSeries"> </Style> </telerik:CategoricalSeriesDescriptor.Style> </telerik:CategoricalSeriesDescriptor> </telerik:ChartSeriesProvider.SeriesDescriptors> {{endregion}}