```
+**C#**
+```diff
+new TabBar()
+ .Grid(row: 2)
++ .SafeArea(SafeArea.InsetMask.Bottom, SafeArea.InsetMode.Margin)
+ .Background(Colors.Purple)
+```
![safearea_with_margin_alpha](../assets/safearea_with_margin.png)
-
***
### Using `InsetMask.SoftInput` for on-screen keyboards
@@ -204,6 +321,7 @@ Notice in this first example (without `SafeArea` in use) that the Username and P
|
+**XAML**
```xml
@@ -245,6 +363,51 @@ Notice in this first example (without `SafeArea` in use) that the Username and P
```
+**C#**
+```cs
+new Grid()
+ .Padding(new Thickness(50,0,50,0))
+ // 0: Logo, 1: Spacing, 2: FormPanel
+ .RowDefinitions("Auto, 40, *")
+ .Children(
+ // Logo
+ new Image()
+ .Source("ms-appx:///Assets/uno-logo.png")
+ .VerticalAlignment(VerticalAlignment.Stretch)
+ .HorizontalAlignment(HorizontalAlignment.Stretch),
+ // FormPanel
+ new StackPanel()
+ .Grid(row: 2)
+ .Spacing(20)
+ .Children(
+ new TextBlock()
+ .Text("Welcome to Uno!")
+ .HorizontalAlignment(HorizontalAlignment.Center)
+ .FontSize(35),
+ new PersonPicture()
+ .ProfilePicture("ms-appx:///Assets/profile.png"),
+ new TextBox()
+ .PlaceholderText("Username"),
+ new StackPanel()
+ .Orientation(Orientation.Horizontal)
+ .Spacing(4)
+ .Children(
+ new CheckBox()
+ .Padding(0)
+ .MinWidth(0),
+ new TextBlock()
+ .Text("Remember me")
+ .VerticalAlignment(VerticalAlignment.Center)
+ ),
+ new Button()
+ .Content("Login")
+ .VerticalAlignment(VerticalAlignment.Top)
+ .HorizontalAlignment(HorizontalAlignment.Stretch)
+ .Margin(new Thickness(0, 30, 0, 30))
+ )
+ )
+
+```
|
@@ -255,12 +418,13 @@ In this next example, we attempt to have the UI adapt to the keyboard by attachi
Page |
- XAML |
+ Code |
|
+**XAML**
```diff
```
+**C#**
+```diff
+new StackPanel()
+ .Grid(row: 2)
++ .SafeArea(SafeArea.InsetMask.SoftInput)
+ .Spacing(20)
+ .Children(
+ new TextBlock()
+ .Text("Welcome to Uno!")
+ .HorizontalAlignment(HorizontalAlignment.Center)
+ .FontSize(35),
+ new PersonPicture()
+ .ProfilePicture("ms-appx:///Assets/profile.png"),
+ new TextBox()
+ .PlaceholderText("Username"),
+ new StackPanel()
+ .Orientation(Orientation.Horizontal)
+ .Spacing(4)
+ .Children(
+ new CheckBox()
+ .Padding(0)
+ .MinWidth(0),
+ new TextBlock()
+ .Text("Remember me")
+ .VerticalAlignment(VerticalAlignment.Center)
+ ),
+ new Button()
+ .Content("Login")
+ .VerticalAlignment(VerticalAlignment.Top)
+ .HorizontalAlignment(HorizontalAlignment.Stretch)
+ .Margin(new Thickness(0, 30, 0, 30))
+ )
+```
|
@@ -328,37 +525,55 @@ There are alternative usages of `SafeArea` that may be considered in this situat
1. Have your own ScrollViewer defined within the XAML and then you can simply wrap that `ScrollViewer` with any container, such as `Grid`, and use the `SafeArea` attached properties on that wrapping container.
-
-
- Page |
- XAML |
-
-
+
+
+ Page |
+ Code |
+
+
|
-
+ |
- ```diff
-
- +
- +
-
-
-
-
-
-
-
- ...
- +
- +
-
-
- ```
+**XAML**
+```diff
+
++
++
+
+
+
+
+
+
+
+ ...
++
++
+
+
+```
+**C#**
+```diff
++ new Grid()
++ .SafeArea(SafeArea.InsetMask.SoftInput)
++ .Children(
++ new ScrollViewer()
++ .Content(
+ new Grid()
+ .Padding(new Thickness(50,0,50,0))
+ // 0: Logo, 1: Spacing, 2: FormPanel
+ .RowDefinitions("Auto, 40, *")
+ .Children(
+ ...
+ )
++ )
++ )
+```
- |
-
-
+
+
+
2. If you do not want to have the whole page scrollable, you could wrap only the FormPanel `StackPanel` within a `SafeArea` instead of the root `Grid`. This may not always have the best visual effect as can be seen in the demonstration below
diff --git a/doc/getting-started.md b/doc/getting-started.md
index a0fa984fb..fb9a3d198 100644
--- a/doc/getting-started.md
+++ b/doc/getting-started.md
@@ -7,6 +7,9 @@ uid: Toolkit.GettingStarted
The Uno.Toolkit library is available as NuGet packages that can be added to any new or existing Uno solution.
+> [!NOTE]
+> The Toolkit library also has support for C# Markup through a [Uno.Toolkit.WinUI.Markup](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Markup) NuGet Package. To get started with Toolkit in your C# Markup application, add the `Uno.Toolkit.WinUI.Markup` NuGet package to your **App Code Library** project and your platform heads.
+
> [!NOTE]
> As of [Uno 4.7](https://platform.uno/blog/uno-platform-4-7-new-project-template-performance-improvements-and-more/), the solution template of an Uno app has changed. There is no longer a Shared project (.shproj), it has been replaced with a regular cross-platform library containing all user code files, referred to as the **App Code Library** project. This also implies that package references can be included in a single location without the previous need to include those in all project heads.
@@ -19,23 +22,39 @@ This article is a guide for installing the base Uno.Toolkit library, additional
1. Open an existing Uno project, or create a new Uno project using the `Multi-Platform App (Uno Platform)` template.
2. In the Solution Explorer panel, right-click on your app's **App Code Library** project (`PROJECT_NAME.csproj`) and select `Manage NuGet Packages...`
-3. Install the [**`Uno.Toolkit.WinUI`**](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material) package
-4. Add the resources to `AppResources.xaml`:
-
- ```xml
-
-
+3. Install the [**`Uno.Toolkit.WinUI`**](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material) package for XAML or [**`Uno.Toolkit.WinUI.Markup`**](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Markup) for C# Markup.
+4. Add the resources to the `AppResources` file:
+# [**XAML**](#tab/xaml)
+```xml
+
+
-
-
+
+
-
-
-
-
-
- ```
+
+
+
+
+```
+# [**C#**](#tab/csharp)
+```cs
+public sealed class AppResources : ResourceDictionary
+{
+ public AppResources()
+ {
+
+ // Load Uno.UI.Toolkit Resources
+ this.Build(r => r.Merged(
+ new ToolkitResources()));
+
+ // Load custom application resources
+ // ...
+ }
+}
+```
+***
#### Previous Installation Method
If your application is based on the older solution template that includes a shared project (.shproj), follow these steps:
@@ -74,17 +93,4 @@ If your application is based on the older solution template that includes a shar
```
-## Using C# Markup
-
-The Toolkit library also has support for C# Markup through a [Uno.Toolkit.WinUI.Markup](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Markup) NuGet Package.
-
-To get started with Toolkit in your C# Markup application, add the `Uno.Toolkit.WinUI.Markup` NuGet package to your **App Code Library** project and your platform heads.
-Then, add the following code to your `AppResources.cs`:
-
-```csharp
-using Uno.Toolkit.UI.Markup;
-
-this.Build(r => r.UseToolkit());
-```
-
> [!NOTE]: If you are using the [Uno.Toolkit.WinUI.Material.Markup](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material.Markup) NuGet package, follow the steps in the [Using C# Markup for the Material Toolkit](./material-getting-started.md#using-c-markup) guide instead as it includes the Toolkit library.
diff --git a/doc/material-getting-started.md b/doc/material-getting-started.md
index c124c6944..3510d2384 100644
--- a/doc/material-getting-started.md
+++ b/doc/material-getting-started.md
@@ -16,7 +16,7 @@ Initialization of the Material Toolkit resources is handled by the specialized `
### `MaterialToolkitTheme`
> [!NOTE]
-> The `MaterialToolkitTheme` class also handles the required initialization of the Uno.Material resources. Therefore, there is no need to initialize `MaterialTheme` within the `AppResources.xaml`
+> The `MaterialToolkitTheme` class also handles the required initialization of the Uno.Material resources. Therefore, there is no need to initialize `MaterialTheme` within the `AppResources` file.
#### Constructors
@@ -34,27 +34,48 @@ Initialization of the Material Toolkit resources is handled by the specialized `
## Installation
+> [!NOTE]
+> The Material Toolkit library also has support for C# Markup through a [Uno.Toolkit.WinUI.Material.Markup](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material.Markup) NuGet Package. To get started with Material Toolkit in your C# Markup application, add the `Uno.Toolkit.WinUI.Material.Markup` NuGet package to your **App Code Library** project and your platform heads.
+
> [!NOTE]
> As of [Uno Platform 4.7](https://platform.uno/blog/uno-platform-4-7-new-project-template-performance-improvements-and-more/), the solution template of the Uno app has changed. There is no longer a Shared project (.shproj), it has been replaced with a regular cross-platform library containing all user code files, referred to as the **App Code Library** project. This also implies that package references can be included in a single location without the previous need to include those in all project heads.
1. Open an existing Uno project, or create a new Uno project using the `Multi-Platform App (Uno Platform)` template.
2. In the Solution Explorer panel, right-click on your app's **App Code Library** project (`PROJECT_NAME.csproj`) and select `Manage NuGet Packages...`
-3. Install the [**`Uno.Toolkit.WinUI.Material`**](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material) package
-4. Add the resources to `AppResources.xaml`:
+3. Install the [**`Uno.Toolkit.WinUI.Material`**](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material) package for XAML or [**`Uno.Toolkit.WinUI.Material.Markup`**](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material.Markup) for C# Markup.
+4. Add the resources to the `AppResources` file:
+# [**XAML**](#tab/xaml)
+```xml
+
+
- ```xml
-
-
+
+
-
-
+
+
-
-
+
+
+```
+# [**C#**](#tab/csharp)
+```cs
+using Uno.Toolkit.UI.Material.Markup;
-
-
- ```
+public sealed class AppResources : ResourceDictionary
+{
+ public AppResources()
+ {
+ // Load Material Toolkit resources (also loads the base Uno.Material resources)
+ this.Build(r => r.Merged(
+ new MaterialToolkitTheme()));
+
+ // Load custom application resources
+ // ...
+ }
+}
+```
+***
### Installing the Material Toolkit on previous versions of Uno Platform
@@ -96,49 +117,52 @@ If your application is based on the older solution template that includes a shar
## Customization
-With `MaterialToolkitTheme`, you do not need to explicitly initialize `MaterialTheme`, `MaterialColors`, or `MaterialFonts`. This means that all resource overrides should go through `MaterialToolkitTheme` itself. There are two properties on `MaterialToolkitTheme` that you can set within your `AppResources.xaml`.
+With `MaterialToolkitTheme`, you do not need to explicitly initialize `MaterialTheme`, `MaterialColors`, or `MaterialFonts`. This means that all resource overrides should go through `MaterialToolkitTheme` itself. There are two properties on `MaterialToolkitTheme` that you can set within your `AppResources`.
### Customize Colors
-Follow the steps [here](https://platform.uno/docs/articles/external/uno.themes/doc/material-getting-started.html#customize-color-palette) to create a `ColorPaletteOverride.xaml` file and add it to your **App Code Library** project (`PROJECT_NAME.csproj`)
+Follow the steps [here](https://platform.uno/docs/articles/external/uno.themes/doc/material-getting-started.html#customize-color-palette) to create a `ColorPaletteOverride` file and add it to your **App Code Library** project (`PROJECT_NAME.csproj`)
-In `AppResources.xaml`, instead of initializing `MaterialColors`, you would use the `ColorOverrideSource` property on `MaterialToolkitTheme`:
+In `AppResources`, instead of initializing `MaterialColors`, you would use the `ColorOverrideSource` property on `MaterialToolkitTheme`:
+# [**XAML**](#tab/xaml)
```xml
-
+
```
+# [**C#**](#tab/csharp)
+```cs
+this.Build(r => r.Merged(
+ new MaterialToolkitTheme(
+ colorOverride: new Styles.ColorPaletteOverride()
+ )
+));
+```
+***
### Customize Fonts
-Follow the steps [here](https://platform.uno/docs/articles/external/uno.themes/doc/material-getting-started.html#change-default-font) to create a `FontOverride.xaml` file and add it to your **App Code Library** project (`PROJECT_NAME.csproj`)
+Follow the steps [here](https://platform.uno/docs/articles/external/uno.themes/doc/material-getting-started.html#change-default-font) to create a `FontOverride` file and add it to your **App Code Library** project (`PROJECT_NAME.csproj`)
-In `AppResources.xaml`, instead of initializing `MaterialFonts`, you would use the `FontOverrideSource` property on `MaterialToolkitTheme`:
+In the `AppResources` file, instead of initializing `MaterialFonts`, you would use the `FontOverrideSource` property on `MaterialToolkitTheme`:
+# [**XAML**](#tab/xaml)
```xml
```
-
-## Using C# Markup
-
-The Material Toolkit library also has support for C# Markup through a [Uno.Toolkit.WinUI.Material.Markup](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material.Markup) NuGet Package.
-
-To get started with Material Toolkit in your C# Markup application, add the `Uno.Toolkit.WinUI.Material.Markup` NuGet package to your **App Code Library** project and your platform heads.
-Then, add the following code to your `AppResources.cs`:
-
-```csharp
-using Uno.Toolkit.UI.Material.Markup;
-
-this.Build(r => r.UseMaterialToolkit(
- //optional
- new Styles.ColorPaletteOverride(),
- //optional
- new Styles.MaterialFontsOverride()
+# [**C#**](#tab/csharp)
+```cs
+this.Build(r => r.Merged(
+ new MaterialToolkitTheme(
+ fontOverride: new Styles.MaterialFontsOverride()
+ )
));
```
+***
-> [!NOTE]: The [Uno.Toolkit.WinUI.Material.Markup](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material.Markup) NuGet package includes the base [Toolkit Markup package](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Markup) as a dependency. Therefore, there is no need to add the `Uno.Toolkit.WinUI.Markup` package separately. Furthermore, the `UseMaterialToolkit` extension method also initializes the Toolkit library, so there is no need to call the `UseToolkit` extension method in your `AppResources.cs`.
+> [!NOTE]
+> The [Uno.Toolkit.WinUI.Material.Markup](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Material.Markup) NuGet package includes the base [Toolkit Markup package](https://www.nuget.org/packages/Uno.Toolkit.WinUI.Markup) as a dependency. Therefore, there is no need to add the `Uno.Toolkit.WinUI.Markup` package separately. Furthermore, the `MaterialToolkitTheme` extension method also initializes the Toolkit library, so there is no need to call the `ToolkitResources` extension method in your `AppResources.cs`.
## Additional Resources