Hi!
I'm trying to change ChartDataMarker's TextColor according to an int property that is converted to some Color based on its value.
I've been using Binding Converter without problems, but with ChartDataMarker it's not working, all label's colors are the same.
Could someone help me?
Thank you!
Converter:
public class IntegerToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var index = (int)value;
if (index < 50)
return Color.FromHex("#ca1d1f");
return Color.FromHex("#000000");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Xaml:
<chart:SfChart>
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis>
<chart:CategoryAxis.Title>
<chart:ChartAxisTitle Text="X" />
chart:CategoryAxis.Title>
chart:CategoryAxis>
chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis>
<chart:NumericalAxis.Title>
<chart:ChartAxisTitle Text="Y" />
chart:NumericalAxis.Title>
chart:NumericalAxis>
chart:SfChart.SecondaryAxis>
<chart:SfChart.Series>
<chart:LineSeries ItemsSource="{Binding PersonList}" XBindingPath="Person" YBindingPath="Grade">
<chart:LineSeries.DataMarker>
<chart:ChartDataMarker>
<chart:ChartDataMarker.LabelStyle>
<chart:DataMarkerLabelStyle TextColor="{Binding Grade, Converter={StaticResource integerToColorConverter}}" />
chart:ChartDataMarker.LabelStyle>
chart:ChartDataMarker>
chart:LineSeries.DataMarker>
chart:LineSeries>
chart:SfChart.Series>
chart:SfChart>