Posted 11 August 2019, 11:53 pm EST
Hi C1,
my use case: I build a C1FlexGrid which does not use default row alternate logic: e.g. we might have several rows for a date value, and all those rows should either have no back color or the default back color.
This gets complicated when using C1Theme where I have to pick the alternate back color from theme.
Attached is a sample.
ThemeTest.zip
Apparently, there are two places where the C1FlexGrid alternate backcolor can be defined:
a) “BaseThemeProperties\AltBackColor”
b) “C1FlexGrid\Styles\Alternate\Background” - this is in my sample style (“RainerOrange”) just a reference to the global “AltBackColor”.
So, I tried to query the current back color this way:
Color colorBack = themeCurrent.GetColor("C1FlexGrid\\Styles\\Alternate\\Background");
This will crash with an “InvalidCastException”.
My workaround:
ThemeItem themeItem = themeCurrent.Children.GetItemByPath("C1FlexGrid\\Styles\\Alternate\\Background");
ThemePropBase propBase = (ThemePropBase)themeItem;
ThemeSolidBackground solidBack = (ThemeSolidBackground) propBase.Value;
Color colorBack = solidBack.Color.Value;
Is it a bug that “themeCurrent.GetColor(“C1FlexGrid\Styles\Alternate\Background”);” does not work? Or should I use a different path?
The base color can be fetched with “themeCurrent.GetColor(“BaseThemeProperties\AltBackColor”);”. But I don’t know whether any of your default themes have a different C1FlexGrid alternate back color, so I don’t know whether is is sufficient to query the back color.
Best regards
Wolfgang