Style and theming with C#
- Dominant language
- No language data
- Stars
- 282
- Forks
- 265
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
I am writing the app UI in C#. Thus C# will my obvious choice for defining styles and themes. Lots of developers who don't know XAML want to do the same. Please add examples of C# in Styles and theming section of the documentation. How I define the Styles:
public static class AppStyles
{
static Color White = Color.FromArgb("#FFFFFF");
static Style whiteRegular20LabelStyle;
public static Style WhiteRegular20LabelStyle => whiteRegular20LabelStyle ?? (whiteRegular20LabelStyle = new Style(
(Label.TextColorProperty, White),
(Label.FontFamilyProperty, "AsapRegular"),
(Label.FontSizeProperty, 20)
));
}
Then use them in code:
`new Label { HorizontalOptions=LayoutOptions.End}.Style(AppStyles.WhiteRegular20LabelStyle),`
I want to theme the app. But don't know how to use SetAppThemeColor and SetAppTheme on styles and controls.
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 04d29bb3-0ea9-e42a-d6d2-cf338baca362
* Version Independent ID: 04d29bb3-0ea9-e42a-d6d2-cf338baca362
* Content: [Theme an app - .NET MAUI](https://docs.microsoft.com/en-us/dotnet/maui/user-interface/theming)
* Content Source: [docs/user-interface/theming.md](https://github.com/dotnet/docs-maui/blob/main/docs/user-interface/theming.md)
* Product: **dotnet-mobile**
* Technology: **dotnet-maui**
* GitHub Login: @davidbritch
* Microsoft Alias: **dabritch**
Contributor guide
Assessment
This issue has not been assessed yet.