When the charts color palette is changed the
legends icons colors does not update to the new color palette.
<Page
x:Class="App2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:chart="using:Syncfusion.UI.Xaml.Charts" ManipulationMode="All"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10">
<Grid.DataContext>
<local:ViewModel/>
</Grid.DataContext>
<StackPanel>
<ComboBox SelectedItem="{x:Bind settings.SelectedChartColorPalette, Mode=TwoWay}" ItemsSource="{x:Bind settings.PaletteList, Mode=OneWay}" >
</ComboBox>
<chart:SfChart x:Name="chart" Palette="{x:Bind settings.SelectedChartColorPalette, Mode=OneWay }">
<chart:SfChart.Legend>
<chart:ChartLegend >
<chart:ChartLegend.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal" Width="Auto" Name="itemwrap"/>
</ItemsPanelTemplate>
</chart:ChartLegend.ItemsPanel>
</chart:ChartLegend>
</chart:SfChart.Legend>
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis />
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis/>
</chart:SfChart.SecondaryAxis>
<chart:ColumnSeries XBindingPath="XValue" YBindingPath="YValue" Label="Column series Legend icon not Changing color"
ItemsSource="{Binding Data}" SegmentSpacing="10.5" />
<chart:LineSeries XBindingPath="XValue" YBindingPath="YValue" Label="Line series Legend icon not Changing color"
ItemsSource="{Binding Data}" />
</chart:SfChart>
</StackPanel>
</Grid>
</Page>
using Syncfusion.UI.Xaml.Charts;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace App2
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
UCChartSettingsViewModel settings = new UCChartSettingsViewModel();
public MainPage()
{
this.InitializeComponent();
}
}
public class Model
{
public double XValue { get; set; }
public double YValue { get; set; }
public Model(double x,double y)
{
XValue = x;
YValue = y;
}
}
public class ViewModel
{
public ViewModel()
{
Data = new ObservableCollection<Model>();
Random rd = new Random();
for (int i = 0; i < 10; i++)
{
Data.Add(new Model(i, rd.Next(0, 100)));
}
}
public ObservableCollection<Model> Data { get; set; }
}
public class UCChartSettingsViewModel : INotifyPropertyChanged
{
private ChartColorPalette selectedColourPalette = new ChartColorPalette();
public event PropertyChangedEventHandler PropertyChanged;
public UCChartSettingsViewModel()
{
this.PaletteList = new ObservableCollection<ChartColorPalette>();
PaletteList.Add(ChartColorPalette.Metro);
PaletteList.Add(ChartColorPalette.AutumnBrights);
PaletteList.Add(ChartColorPalette.FloraHues);
PaletteList.Add(ChartColorPalette.Pineapple);
PaletteList.Add(ChartColorPalette.TomatoSpectrum);
PaletteList.Add(ChartColorPalette.RedChrome);
PaletteList.Add(ChartColorPalette.BlueChrome);
PaletteList.Add(ChartColorPalette.PurpleChrome);
PaletteList.Add(ChartColorPalette.GreenChrome);
PaletteList.Add(ChartColorPalette.Elite);
PaletteList.Add(ChartColorPalette.LightCandy);
PaletteList.Add(ChartColorPalette.SandyBeach);
selectedColourPalette = PaletteList[0];
}
public ObservableCollection<ChartColorPalette> PaletteList
{
get;
set;
}
public ChartColorPalette SelectedChartColorPalette
{
get => selectedColourPalette;
set
{
if (selectedColourPalette != value)
{
selectedColourPalette = value;
NotifyPropertyChanged();
}
}
}
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
Attachment:
App2_cea52bd.zip