Support for AppThemeBindings #75
Replies: 6 comments 2 replies
-
@HobDev you can declare styles and assign them to the Is there something else you would like to see? |
Beta Was this translation helpful? Give feedback.
-
@bijington Thank you for the answer. I want to support dark mode in the app. I am using C# markup to write the UI and styles. I want to use AppThemeBinding to support the light and dark mode. But it does not work. Is it possible to include dark mode support in the sample. Specifically the use of AppThemeBinding. |
Beta Was this translation helpful? Give feedback.
-
@brminnick Can you help with this |
Beta Was this translation helpful? Give feedback.
-
Open an issue for this discussion over here. |
Beta Was this translation helpful? Give feedback.
-
Perhaps we could expose something like: public static VisualElement BackgroundColor(this VisualElement visualElement, Color lightModeColor, Color darkModeColor)
{
AppThemeBinding appThemeBinding = new
{
Light = lightModeColor,
Dark = darkModeColor
};
visualElement.SetBinding(VisualElement.BackgroundColorProperty, appThemeBinding);
return visualElement;
} This would allow for the UI to be built as we currently do but allow for the application to respond to theme changes. We could of course roll this out over all of our other extension methods (e.g. I would need to check whether this works with the Style methods too but I think it should or we should be able to make it work. |
Beta Was this translation helpful? Give feedback.
-
issue #76 answers most of this the rest is being Closed as per the Community Stand-up discussion here: https://youtu.be/N9wMcBP4jtg?t=2889 |
Beta Was this translation helpful? Give feedback.
-
The docs have the
SetAppThemeColor()
andSetAppTheme()
. This way I have to declare the colors on each UI element. There should be some better way to share style among the UI elements in C#. C# markup must support to declare the style once and use it throughout the app.Finally use the style in UI :
new Label{Text = "Hello World" , HorizontalOptions=LayoutOptions.Center, VerticalOptions=LayoutOptions.Center}.Style(AppStyles.labelStyle),
Beta Was this translation helpful? Give feedback.
All reactions