-
Notifications
You must be signed in to change notification settings - Fork 33
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
docs: Adding csharp markup code examples #1309
base: master
Are you sure you want to change the base?
Conversation
@@ -4,31 +4,61 @@ uid: Uno.Themes.Material.Extensions | |||
|
|||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can link back to the Getting Started section that mentions C# Markup with an xref here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
> [!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. |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**XAML**](#tab/xaml) | |
### [**XAML**](#tab/xaml) | |
</ComboBox> | ||
``` | ||
|
||
# [**C#**](#tab/csharp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
### [**C#**](#tab/csharp) | |
.Symbol(Symbol.SolidStar) | ||
) | ||
``` | ||
*** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*** | |
*** | |
</um:ControlExtensions.Icon> | ||
</ComboBox> | ||
``` | ||
# [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**XAML**](#tab/xaml) | |
### [**XAML**](#tab/xaml) | |
</um:ControlExtensions.Icon> | ||
</ComboBox> | ||
``` | ||
# [**C#**](#tab/csharp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
### [**C#**](#tab/csharp) | |
new SymbolIcon() | ||
.Symbol(Symbol.SolidStar) | ||
) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
``` | |
@@ -37,17 +67,36 @@ It's control specific and for now, you can only use it with the ToggleButton con | |||
|
|||
### Alternate Content on ToggleButton | |||
|
|||
# [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**XAML**](#tab/xaml) | |
#### [**XAML**](#tab/xaml) | |
<!-- This is the alternate content - which is when the control state is CHECKED --> | ||
<um:ControlExtensions.AlternateContent> | ||
<PathIcon Data="{StaticResource Icon_more_vertical}" /> | ||
</um:ControlExtensions.AlternateContent> | ||
</ToggleButton> | ||
``` | ||
# [**C#**](#tab/csharp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
#### [**C#**](#tab/csharp) | |
new PathIcon() | ||
.Data(StaticResource.Get<Geometry>("Icon_more_vertical")) | ||
) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
``` | |
@@ -97,6 +146,7 @@ Within the `ControlTemplate` of the `ElevatedButtonStyle`, instead of performing | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**XAML**](#tab/xaml) | |
### [**XAML**](#tab/xaml) | |
@@ -120,11 +170,44 @@ Applying the surface tint for elevated controls is optional and must be explicit | |||
</StackPanel> | |||
``` | |||
|
|||
The above XAML will produce the following result: | |||
# [**C#**](#tab/csharp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
### [**C#**](#tab/csharp) | |
.ControlExtensions(elevation: 5) | ||
.Style(Theme.Button.Styles.Elevated) | ||
) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
``` | |
@@ -34,24 +34,41 @@ Initialization of the Uno.Material resources is handled by the specialized `Mate | |||
| ColorOverrideSource | string | (Optional) Gets or sets a Uniform Resource Identifier that provides the source location of a ResourceDictionary containing overrides for the default Uno.Material Color resources | | |||
| FontOverrideSource | string | (Optional) Gets or sets a Uniform Resource Identifier that provides the source location of a ResourceDictionary containing overrides for the default Uno.Material font resources | | |||
|
|||
> [!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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**XAML**](#tab/xaml) | |
##### [**XAML**](#tab/xaml) | |
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
``` | ||
# [**C#**](#tab/csharp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
##### [**C#**](#tab/csharp) | |
new MaterialTheme())); | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
``` | |
ColorOverrideSource="ms-appx:///PROJECT_NAME/Styles/Application/MaterialColorsOverride.xaml" /> | ||
``` | ||
|
||
# [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**XAML**](#tab/xaml) | |
#### [**XAML**](#tab/xaml) | |
</ResourceDictionary.ThemeDictionaries> | ||
</ResourceDictionary> | ||
``` | ||
# [**C#**](#tab/csharp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
#### [**C#**](#tab/csharp) | |
); | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
``` | |
} | ||
} | ||
``` | ||
*** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*** | |
*** | |
``` | ||
*** | ||
4. In `AppResources` file, update `MaterialTheme` with the override from the previous steps: | ||
# [**XAML**](#tab/xaml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
##### [**C#**](#tab/csharp) | |
new MaterialTheme() | ||
.ColorOverrideDictionary(new Styles.ColorPaletteOverride()))); | ||
``` | ||
*** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*** | |
*** | |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
#### [**C#**](#tab/csharp) | |
.Add<FontFamily>("MaterialRegularFontFamily", "ms-appx:///PROJECT_NAME/Assets/Fonts/MyCustomFont-Regular.ttfMyCustomFont")); | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
``` | |
//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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [**C#**](#tab/csharp) | |
#### [**C#**](#tab/csharp) |
``` | ||
*** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*** | |
*** |
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):