Access to theme colors in custom styling logic #26
wolframhaussig
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My usecase
I have an application with a
StylableDataGridViewwhere I use theRowPrePaintevent to update the backcolor of each row based on the value in a specific column. My problem is: theStylableDataGridView_RowPrePaintimplementation can get as far asThemeRegistryHolder.ThemeRegistry.Currentto get the theme but it has no access to the colors used.Workarounds
var color = ThemeRegistryHolder.ThemeRegistry.Current.Capabilities.HasFlag(ThemeCapabilities.DarkMode) ? Color.DarkGrey : Color.Grey, but this does only work for the default themes - when the colors change this would look weird.IThemePlugin: this works, as we get access to the colors in theApplymethod by accessing theAbstractThemebut it would require the reimplementation of the completeStylableDataGridViewstyling logic.AbstractTheme: We could call the parentApplymethod to get the defaultStylableDataGridViewstyling and then apply custom styling. The downside is that we would need to do that for each theme that should be supported and it would break when a non-customized theme would be used.The question
Basically, my question is: How can we provide access to the colors of a theme to custom code? The current implementation only provides access to colors for:
Every other caller only has access to the
IThemeinterface which only supports applying it to forms and controls (we do not want to mention casting it to anAbstractThemehere to access the colors).Possible Solutions
Currently, I am thinking of separating colors from themes (as I already mentioned in #9):
AbstractThemetoDefaultThemeand make it non-abstractFileThemewould be restructured to not be a theme but only a holder for the given colors and would be renamed toThemeDesignThemeDesigncould support easy configuration by configuring the main colors only while the other colors woulds be calculated form there(like we do inDefaultLightThemefor example)ResourceThemeLookupandFileThemeLookupwould not create aFileTheme, but aDefaultThemewith theThemeDesignloaded from the given resourceIThemeinterface would get a property for reading the assignedThemeDesignobject which I could use in my usecase above to do custom styling/cc @Nockiro
Beta Was this translation helpful? Give feedback.
All reactions