docs: Adding csharp markup code examples#1309
Conversation
| # Material Control Extensions | ||
|
|
||
| > [!NOTE] | ||
| > Uno Material also has support for C# Markup through a [Uno.Material.WinUI.Markup](https://www.nuget.org/packages/Uno.Material.WinUI.Markup) NuGet Package. To get started with Uno Material in your C# Markup application, add the `Uno.Material.WinUI.Markup` NuGet package to your **App Code Library** project and your platform heads. |
There was a problem hiding this comment.
We can link back to the Getting Started section that mentions C# Markup with an xref here
There was a problem hiding this comment.
Huum, I removed the Using C# Markup section from that page, since all the C# Markup code is now integrated in the tabs with the Xaml ones, and added a similar note to that page instead:
Uno.Themes/doc/material-getting-started.md
Lines 37 to 38 in 931cbd5
Do you think it's better to bring back that section?
| </um:ControlExtensions.Icon> | ||
| </ComboBox> | ||
| ``` | ||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| ### [**XAML**](#tab/xaml) | |
| </ComboBox> | ||
| ``` | ||
|
|
||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| ### [**C#**](#tab/csharp) | |
| .Symbol(Symbol.SolidStar) | ||
| ) | ||
| ``` | ||
| *** |
| </um:ControlExtensions.Icon> | ||
| </ComboBox> | ||
| ``` | ||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| ### [**XAML**](#tab/xaml) | |
| </um:ControlExtensions.Icon> | ||
| </ComboBox> | ||
| ``` | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| ### [**C#**](#tab/csharp) | |
| new SymbolIcon() | ||
| .Symbol(Symbol.SolidStar) | ||
| ) | ||
| ``` |
|
|
||
| ### Alternate Content on ToggleButton | ||
|
|
||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| #### [**XAML**](#tab/xaml) | |
| </um:ControlExtensions.AlternateContent> | ||
| </ToggleButton> | ||
| ``` | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| #### [**C#**](#tab/csharp) | |
| new PathIcon() | ||
| .Data(StaticResource.Get<Geometry>("Icon_more_vertical")) | ||
| ) | ||
| ``` |
|
|
||
| Applying the surface tint for elevated controls is optional and must be explicitly enabled through the use of the `IsTintEnabled` attached property. Below is an example of how an elevated control may appear with or without a surface tint: | ||
|
|
||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| ### [**XAML**](#tab/xaml) | |
| ``` | ||
|
|
||
| The above XAML will produce the following result: | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| ### [**C#**](#tab/csharp) | |
| .ControlExtensions(elevation: 5) | ||
| .Style(Theme.Button.Styles.Elevated) | ||
| ) | ||
| ``` |
|
|
||
| > [!NOTE] | ||
| > Uno Material also has support for C# Markup through a [Uno.Material.WinUI.Markup](https://www.nuget.org/packages/Uno.Material.WinUI.Markup) NuGet Package. To get started with Uno Material in your C# Markup application, add the `Uno.Material.WinUI.Markup` NuGet package to your **App Code Library** project and your platform heads. | ||
|
|
| 3. Install the [`Uno.Material.WinUI`](https://www.nuget.org/packages/Uno.Material.WinUI) for XAML or [`Uno.Material.WinUI.Markup`](https://www.nuget.org/packages/Uno.Material.WinUI.Markup) for C# Markup. | ||
| 4. Add the following Material resources to `AppResources`: | ||
|
|
||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| ##### [**XAML**](#tab/xaml) | |
| </ResourceDictionary.MergedDictionaries> | ||
| </ResourceDictionary> | ||
| ``` | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| ##### [**C#**](#tab/csharp) | |
| new MaterialTheme())); | ||
| } | ||
| } | ||
| ``` |
| ColorOverrideSource="ms-appx:///PROJECT_NAME/Styles/Application/MaterialColorsOverride.xaml" /> | ||
| ``` | ||
|
|
||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| #### [**XAML**](#tab/xaml) | |
| </ResourceDictionary.ThemeDictionaries> | ||
| </ResourceDictionary> | ||
| ``` | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| #### [**C#**](#tab/csharp) | |
| ); | ||
| } | ||
| } | ||
| ``` |
| } | ||
| } | ||
| ``` | ||
| *** |
| ``` | ||
| *** | ||
| 4. In `AppResources` file, update `MaterialTheme` with the override from the previous steps: | ||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| ##### [**XAML**](#tab/xaml) | |
| <MaterialTheme xmlns="using:Uno.Material" | ||
| ColorOverrideSource="ms-appx:///PROJECT_NAME/Styles/Application/MaterialColorsOverride.xaml" /> | ||
| ``` | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| ##### [**C#**](#tab/csharp) | |
| new MaterialTheme() | ||
| .ColorOverrideDictionary(new Styles.ColorPaletteOverride()))); | ||
| ``` | ||
| *** |
| 2. In the application's **App Code Library** project (`PROJECT_NAME.csproj`), add a new Resource Dictionary named `MaterialFontsOverride.xaml` for XAML or a new class inheriting from `ResourceDictionary` named `MaterialFontsOverride.cs` for C# Markup | ||
| 3. Save the new override file within the **App Code Library**, for example, under `Styles/Application`. | ||
| 4. Assuming the font file has been placed in the **App Code Library** within, for example, a directory such as `Assets/Fonts/MyCustomFont.ttf`, your override file would look like the following: | ||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| #### [**XAML**](#tab/xaml) | |
| <FontFamily x:Key="MaterialRegularFontFamily">ms-appx:///PROJECT_NAME/Assets/Fonts/MyCustomFont-Regular.ttfMyCustomFont</FontFamily> | ||
| </ResourceDictionary> | ||
| ``` | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| #### [**C#**](#tab/csharp) | |
| .Add<FontFamily>("MaterialRegularFontFamily", "ms-appx:///PROJECT_NAME/Assets/Fonts/MyCustomFont-Regular.ttfMyCustomFont")); | ||
| } | ||
| } | ||
| ``` |
| //optional | ||
| new Styles.MaterialFontsOverride())); | ||
| 5. In `AppResources` file, update `MaterialTheme` with the override from the previous steps: | ||
| # [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
| # [**XAML**](#tab/xaml) | |
| #### [**XAML**](#tab/xaml) | |
| <MaterialTheme xmlns="using:Uno.Material" | ||
| FontOverrideSource="ms-appx:///PROJECT_NAME/Styles/Application/MaterialFontsOverride.xaml" /> | ||
| ``` | ||
| # [**C#**](#tab/csharp) |
There was a problem hiding this comment.
| # [**C#**](#tab/csharp) | |
| #### [**C#**](#tab/csharp) |
| new MaterialTheme() | ||
| .FontOverrideDictionary(new Styles.MaterialFontsOverride()))); | ||
| ``` | ||
| *** |
GitHub Issue: #1302
PR Type
What kind of change does this PR introduce?
Description
PR Checklist
Please check if your PR fulfills the following requirements:
Other information
Internal Issue (If applicable):