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

docs: Adding csharp markup code examples #1309

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

eriklimakc
Copy link
Contributor

GitHub Issue: #1302

PR Type

What kind of change does this PR introduce?

  • Documentation content changes

Description

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

@eriklimakc eriklimakc self-assigned this Dec 18, 2023
@eriklimakc eriklimakc marked this pull request as ready for review December 18, 2023 13:21
@@ -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.
Copy link
Collaborator

@kazo0 kazo0 Dec 21, 2023

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

Copy link
Contributor Author

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:

> [!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?

@kazo0

</um:ControlExtensions.Icon>
</ComboBox>
```
# [**XAML**](#tab/xaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**XAML**](#tab/xaml)
### [**XAML**](#tab/xaml)

</ComboBox>
```

# [**C#**](#tab/csharp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
### [**C#**](#tab/csharp)

.Symbol(Symbol.SolidStar)
)
```
***
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
***
***

</um:ControlExtensions.Icon>
</ComboBox>
```
# [**XAML**](#tab/xaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**XAML**](#tab/xaml)
### [**XAML**](#tab/xaml)

</um:ControlExtensions.Icon>
</ComboBox>
```
# [**C#**](#tab/csharp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
### [**C#**](#tab/csharp)

new SymbolIcon()
.Symbol(Symbol.SolidStar)
)
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
#### [**C#**](#tab/csharp)

new PathIcon()
.Data(StaticResource.Get<Geometry>("Icon_more_vertical"))
)
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
### [**C#**](#tab/csharp)

.ControlExtensions(elevation: 5)
.Style(Theme.Button.Styles.Elevated)
)
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```

@@ -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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**XAML**](#tab/xaml)
##### [**XAML**](#tab/xaml)

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
```
# [**C#**](#tab/csharp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
##### [**C#**](#tab/csharp)

new MaterialTheme()));
}
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```

ColorOverrideSource="ms-appx:///PROJECT_NAME/Styles/Application/MaterialColorsOverride.xaml" />
```

# [**XAML**](#tab/xaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**XAML**](#tab/xaml)
#### [**XAML**](#tab/xaml)

</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
```
# [**C#**](#tab/csharp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
#### [**C#**](#tab/csharp)

);
}
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```

}
}
```
***
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
***
***

```
***
4. In `AppResources` file, update `MaterialTheme` with the override from the previous steps:
# [**XAML**](#tab/xaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**XAML**](#tab/xaml)
##### [**XAML**](#tab/xaml)

<MaterialTheme xmlns="using:Uno.Material"
ColorOverrideSource="ms-appx:///PROJECT_NAME/Styles/Application/MaterialColorsOverride.xaml" />
```
# [**C#**](#tab/csharp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
##### [**C#**](#tab/csharp)

new MaterialTheme()
.ColorOverrideDictionary(new Styles.ColorPaletteOverride())));
```
***
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
***
***

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**XAML**](#tab/xaml)
#### [**XAML**](#tab/xaml)

<FontFamily x:Key="MaterialRegularFontFamily">ms-appx:///PROJECT_NAME/Assets/Fonts/MyCustomFont-Regular.ttfMyCustomFont</FontFamily>
</ResourceDictionary>
```
# [**C#**](#tab/csharp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
#### [**C#**](#tab/csharp)

.Add<FontFamily>("MaterialRegularFontFamily", "ms-appx:///PROJECT_NAME/Assets/Fonts/MyCustomFont-Regular.ttfMyCustomFont"));
}
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```

//optional
new Styles.MaterialFontsOverride()));
5. In `AppResources` file, update `MaterialTheme` with the override from the previous steps:
# [**XAML**](#tab/xaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**XAML**](#tab/xaml)
#### [**XAML**](#tab/xaml)

<MaterialTheme xmlns="using:Uno.Material"
FontOverrideSource="ms-appx:///PROJECT_NAME/Styles/Application/MaterialFontsOverride.xaml" />
```
# [**C#**](#tab/csharp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# [**C#**](#tab/csharp)
#### [**C#**](#tab/csharp)

```
***
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
***
***

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

Successfully merging this pull request may close these issues.

None yet

4 participants