Hello,
I would like to use for each column in a ColumnSeries a different color based on the default color palette of the theme. How Can I do that?
Currently it looks like:
Dear Markus,
You can achieve that by handling the event AssigningCategoryStyle of the ColumnSeries class. The event arguments allow you to specify the color to be used for each column.
I have attached a sample which colors the columns based on the value of the column.
Should you have any further questions, please let me know.
Sincerely
0003.ColumnSeriesWithDifferentColors.zip
Thanks! But how can I access the default or standard chart color palette, in order I can use the predefined colors for a given theme?
Hello Markus,
I have attached a sample with Metro Theme applied to xamDataChart with Column Series, and the color of the columns is set to some of the colors of the theme.
All the available colors from this theme are in file Metro.Theme.Colors.xaml, and you can bind the color of the columns by referencing the key of the code, or you can simply copy paste the hex color code into your application.
Please let me know if you have more questions.
5861.ColumnSeries.zip
Thank you very much.
I am using ThemeManager.ApplicationTheme = new Infragistics.Themes.MetroDarkTheme(); to load the proper theme.
Is it also possible to use the colors from the applied ApplicationTheme? Is there a generic way to access the default chart colors, without using the specialised theme xaml file?
By applying the selected theme, you are already using the xaml files.
ThemeManager does the merging of the resources for you, so accessing the colors used in the theme from code behind will still go with the following piece of code:
(Application.Current.Resources.MergedDictionaries[0])["ColorNumber"]
This means that the code above will be referencing to colors used in the MetroDarkTheme in your case.
If you do not want to use the theme files at all, you can just retrieve the color codes and use them without a theme, applying them to the control UI as per your requirements.
Should you have more questions, please let me know.
Using
string color = "Color_00" + $"{value}";Color color1 = (Color)(Application.Current.Resources.MergedDictionaries[0])[color];
doesn't use the themed chart colors. In my case the colores are different from black to white.
Any suggestion?
MetroDark theme uses 75 different colors, with nearly 30 of them being black and white shades. It is very likely that all colors you have chosen to be out of them, so please refer to the documentation in the xaml file, and choose accent or chart series colors.
As per my previous reply, you can check all of the colors in the MetroDark.Theme.Colors.xaml file. The path of the file should be something like C:\Program Files (x86)\Infragistics\2019.1\WPF\Themes\MetroDark. After that you can right click on the file and click "Edit". If you do not have an editor, notepad will do. From there you can see all the colors, with comments:
<!--Base Colors--> <Color x:Key="Color_000">#FF282828</Color> <Color x:Key="Color_001">#FFFFFFFF</Color> <!--Transparent and Whites with transparency--> <Color x:Key="Color_010">#E5FFFFFF</Color> <!--90% White--> <Color x:Key="Color_011">#BFFFFFFF</Color> <!--75% White--> <!--Theme Accent colors --> <Color x:Key="Color_023">#FF0086AF</Color> <Color x:Key="Color_024">#FF00AADE</Color> <!--Colors for Chart Series--> <Color x:Key="Color_035">#FF006481</Color> <Color x:Key="Color_037">#FF8A9B0F</Color>