Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for AppThemeBindings #76

Closed
HobDev opened this issue Jun 25, 2022 Discussed in #75 · 1 comment
Closed

Support for AppThemeBindings #76

HobDev opened this issue Jun 25, 2022 Discussed in #75 · 1 comment

Comments

@HobDev
Copy link
Contributor

HobDev commented Jun 25, 2022

Discussed in #75

Originally posted by HobDev June 23, 2022
The docs have the SetAppThemeColor() and SetAppTheme(). 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.

 static Color darkThemeTextColor = Color.FromArgb("#FFFFFF");
        static Color lightThemeTextColor = Color.FromArgb("#000000");

        static Style<Label> cSharpLabelStyle;
        public static Style<Label> CSharpLabelStyle => cSharpLabelStyle ?? (cSharpLabelStyle = new Style<Label>(
        (Label.TextColorProperty, new AppThemeBindingExtension { Dark = darkThemeTextColor, Light = lightThemeTextColor }),
        (Label.FontFamilyProperty, "OpenSansRegular"),
       (Label.FontSizeProperty, 14)
       ));

Finally use the style in UI :

new Label{Text = "Hello World" , HorizontalOptions=LayoutOptions.Center, VerticalOptions=LayoutOptions.Center}.Style(AppStyles.CSharpLabelStyle),

In the attached sample the color of the XAML Label changes with the change of mode. But the C# Label does not change color until the app restarts. Unable to check the change of device theme due to this bug.

MauiApp1.zip

@brminnick
Copy link
Collaborator

brminnick commented Jun 25, 2022

@HobDev It doesn't look like the Discussion in #75 is complete.

Please propose an API design and example of the new features usage in #75.

Once the feature has been fully fleshed out, you will open a New Feature Proposal.

For more information see the instructions for Submitting A New Feature in the README: https://github.com/CommunityToolkit/Maui.Markup#submitting-a-new-feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants