### Install Uno Platform CLI Templates
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/getting-started.md
Installs the Uno Platform project templates for use with the .NET command-line interface. This is a prerequisite for creating new projects using the CLI.
```bash
dotnet new install Uno.Templates
```
--------------------------------
### Create New Uno App with Toolkit via CLI
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/getting-started.md
Creates a new Uno Platform application named 'ToolkitApp' using the command-line interface, automatically including the Uno Toolkit feature during project generation.
```bash
dotnet new unoapp -o ToolkitApp -toolkit
```
--------------------------------
### Initialize ToolkitResources in Single Project App.xaml
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/getting-started.md
Adds the ToolkitResources resource dictionary to the Application.Resources in App.xaml for a Single Project template, making Uno Toolkit styles and templates available application-wide.
```xml
```
--------------------------------
### Add ToolkitResources to Multi-Head AppResources.xaml
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/getting-started.md
Includes the ToolkitResources dictionary within the MergedDictionaries of AppResources.xaml for a Multi-Head project template, providing access to Uno Toolkit resources.
```xml
```
--------------------------------
### Installing Uno Platform CLI Templates (Bash)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/cupertino-getting-started.md
Installs the necessary `dotnet new` templates for creating Uno Platform projects, including those with toolkit options. This is a prerequisite for creating new projects using the CLI.
```Bash
dotnet new install Uno.Templates
```
--------------------------------
### Install Uno Platform CLI Templates - Bash
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/material-getting-started.md
Installs the latest Uno Platform project templates for use with the .NET command-line interface.
```bash
dotnet new install Uno.Templates
```
--------------------------------
### Configuring Uno Toolkit with C# Markup
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/getting-started.md
This snippet shows how to initialize the Uno Toolkit library in an application using C# Markup. It requires adding the `Uno.Toolkit.WinUI.Markup` NuGet package and calling the `UseToolkit` extension method on the application builder.
```csharp
using Uno.Toolkit.UI.Markup;
this.Build(r => r.UseToolkit());
```
--------------------------------
### Add ToolkitResources and WinUI Resources to Shared Project App.xaml
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/getting-started.md
Adds both the standard WinUI XamlControlsResources and the Uno ToolkitResources to the Application.Resources in App.xaml for a Shared Project template, ensuring both sets of resources are available.
```xml
```
--------------------------------
### Add Uno Toolkit Feature to Single Project .csproj
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/getting-started.md
Modifies the project file (.csproj) for a Single Project template to include 'Toolkit' in the list of UnoFeatures, enabling the Uno Toolkit integration.
```xml
Toolkit
```
--------------------------------
### Creating New Uno App with Cupertino Toolkit (Bash)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/cupertino-getting-started.md
Creates a new Uno Platform application project named `CupertinoToolkitApp`. The `-toolkit` flag includes the Uno Toolkit, and `-theme cupertino` configures it to use the Cupertino theme by default.
```Bash
dotnet new unoapp -o CupertinoToolkitApp -toolkit -theme cupertino
```
--------------------------------
### Example Asset File Paths
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples/Assets/SharedAssets.md
This snippet shows example file path structures for organizing image assets within the 'Assets' directory of a shared project. It demonstrates two common patterns for naming or organizing files to support different display scales (100, 200, 400). These structures help the platform automatically select the appropriate asset based on the device's DPI.
```text
\Assets\Images\logo.scale-100.png
\Assets\Images\logo.scale-200.png
\Assets\Images\logo.scale-400.png
\Assets\Images\scale-100\logo.png
\Assets\Images\scale-200\logo.png
\Assets\Images\scale-400\logo.png
```
--------------------------------
### Adding Uno Toolkit Features to Single Project (XML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/cupertino-getting-started.md
Modifies the `.csproj` file in a Single Project template to explicitly include the `Toolkit` and `Cupertino` features. This enables the use of Uno Toolkit and Cupertino styles and controls.
```XML
Toolkit;Cupertino
```
--------------------------------
### Retrieving Current OS Theme using SystemThemeHelper (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/SystemThemeHelper.md
Demonstrates how to use the GetCurrentOsTheme method of SystemThemeHelper to get the current operating system theme and print it to the console.
```csharp
var osTheme = SystemThemeHelper.GetCurrentOsTheme();
Console.WriteLine($"Current OS Theme: {osTheme}");
```
--------------------------------
### Initializing Cupertino Toolkit Resources in App.xaml (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/cupertino-getting-started.md
Adds `ResourceDictionary` entries to the application's resources in `App.xaml`. This merges the necessary Cupertino core resources (`CupertinoColors`, `CupertinoFonts`, `CupertinoResources`) and the Cupertino Toolkit resources (`ToolkitResources`, `CupertinoToolkitResources`) for use throughout the application.
```XML
```
--------------------------------
### Using LoadingView with Single and Multiple Sources (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/LoadingView.md
This XAML snippet demonstrates two common usage patterns for the `LoadingView` control. The first example shows binding to a single `Source` (like an `AsyncCommand`) and defining custom `LoadingContent`. The second example illustrates using `CompositeLoadableSource` to track the loading state of multiple sources simultaneously, displaying a simple `ProgressRing` as loading content.
```xml
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Adding Cupertino Toolkit Resources to App.xaml (Shared Project) (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/cupertino-getting-started.md
Merges the necessary WinUI, Cupertino core, and Cupertino Toolkit resources into the `App.xaml` file for a Shared Project template. This ensures that all required styles and controls are available across the various platform heads referencing the shared project.
```XML
```
--------------------------------
### Example ViewModel for LoadingView (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/LoadingView.md
This C# class `ViewModel` serves as an example for integrating with `LoadingView`. It defines properties (`Content0`, `Content1`) and `AsyncCommand` instances (`LoadContent0Command`, `LoadContent1Command`) that represent asynchronous operations. The `AsyncCommand` instances are designed to be bound to the `LoadingView`'s `Source` property, allowing the UI to react to their execution state.
```csharp
private class ViewModel : ViewModelBase
{
public string Content0 { get => GetProperty(); set => SetProperty(value); }
public IEnumerable Content1 { get => GetProperty>(); set => SetProperty(value); }
public AsyncCommand LoadContent0Command { get; }
public AsyncCommand LoadContent1Command { get; }
private readonly Random _random = new Random();
public ViewModel()
{
LoadContent0Command = new AsyncCommand(LoadContent0);
LoadContent1Command = new AsyncCommand(LoadContent1);
}
public Task LoadContent0() => SimulateFetchOrWork(500, () => Content0 = DateTime.Now.ToString());
public Task LoadContent1() => SimulateFetchOrWork(2000, () => Content1 = Enumerable.Range(0, _random.Next(3, 12)));
private async Task SimulateFetchOrWork(int delay, Action onCompleted)
{
await Task.Delay(delay);
onCompleted();
}
}
```
--------------------------------
### Examples of Chip Usage and Styling (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ChipAndChipGroup.md
Illustrates how to use the Chip control in XAML with different predefined styles (Assist, Input, Filter, Suggestion) and demonstrates how to embed an image as the Icon content.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Adding Cupertino Toolkit Resources to AppResources.xaml (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/cupertino-getting-started.md
Merges the required Cupertino core resources (`CupertinoColors`, `CupertinoFonts`, `CupertinoResources`) and the Cupertino Toolkit resources (`ToolkitResources`, `CupertinoToolkitResources`) into the `AppResources.xaml` file. This makes the Cupertino styles and controls available to the application's shared code library.
```XML
```
--------------------------------
### Define Example Data Model (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/ancestor-itemscontrol-binding.md
Defines a simple C# class used as a DataContext in the XAML examples to demonstrate binding to properties within and outside of an ItemsControl's ItemTemplate.
```C#
public class ExampleModel
{
public int[] Items { get; } = new[] { 1, 2, 3 };
public string SomeText { get; } = "Lorem Ipsum";
}
```
--------------------------------
### Define Example Data Model (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/ancestor-itemscontrol-binding.md
Defines a simple C# class used as a DataContext in the XAML examples to demonstrate binding to properties within and outside of an ItemsControl's ItemTemplate. This is a repeat of the model definition for context before the second XAML example.
```C#
public class ExampleModel
{
public int[] Items { get; } = new[] { 1, 2, 3 };
public string SomeText { get; } = "Lorem Ipsum";
}
```
--------------------------------
### Applying Windows Style to NavigationBar (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/NavigationBar.md
Example of applying the XamlDefaultNavigationBar style to the NavigationBar control, configuring it for the Windows-like appearance using a custom-styled CommandBar.
```XAML
```
--------------------------------
### Implementing Incremental Loading Source in C#
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/itemsrepeater-extensions.md
Provides a basic ViewModel structure and an example implementation of the ISupportIncrementalLoading interface required for incremental loading with ItemsRepeaterExtensions. The InfiniteSource class demonstrates the necessary HasMoreItems property and LoadMoreItemsAsync method.
```csharp
private class ViewModel : INotifyPropertyChanged
{
public bool IsLoading { get; set; }
public InfiniteSource InfiniteItemsSource { get; set; }
}
...
public class InfiniteSource : ISupportIncrementalLoading
{
public bool HasMoreItems { get; set; } = true;
public Task LoadMoreItemsAsync(uint count)
{
// Load more items
}
}
```
--------------------------------
### Using Uno Toolkit InputExtensions in XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/Input-extensions.md
Demonstrates how to apply the InputExtensions attached properties (AutoFocusNext, AutoFocusNextElement, AutoDismiss, ReturnType) to TextBox controls in XAML. Shows examples for controlling focus movement, dismissing the keyboard, and changing the soft keyboard return key type.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Using the ChipGroup Control in XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ChipAndChipGroup.md
This snippet demonstrates how to declare and use the ChipGroup control in XAML, including the necessary namespace declaration and examples of basic usage.
```xaml
xmlns:utu="using:Uno.Toolkit.UI"
...
-or-
oneOrMoreItems
```
--------------------------------
### Defining Color for Android Styles (Colors.xml)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/NavigationBar.md
Provides an example of how to define a color resource in an Android Colors.xml file, which can then be referenced in Android styles to apply specific colors to UI elements.
```XML
#FFFF0000
```
--------------------------------
### ViewModel for Controlling Visual States in C#
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/VisualStateManager-extensions.md
Provides a C# ViewModel implementation that complements the XAML usage example. It includes a bindable `PageState` property that the XAML attached property `utu:VisualStateManagerExtensions.States` can bind to, and a command to change this state programmatically.
```C#
public class ViewModel : ViewModelBase
{
public string PageState { get => GetProperty(); set => SetProperty(value); }
public ICommand ChangePageStateCommand => new Command(ChangePageState);
public ViewModel()
{
PageState = "Blue";
}
private void ChangePageState(object parameter)
{
if (parameter is string state)
{
PageState = state;
}
}
}
```
--------------------------------
### Applying Native Style to NavigationBar (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/NavigationBar.md
Example of applying the NativeDefaultNavigationBar style to the NavigationBar control, configuring it for a platform-native appearance on Android and iOS using underlying native controls.
```XAML
```
--------------------------------
### Using ShadowContainer with StaticResource Shadows (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ShadowContainer.md
Demonstrates applying predefined shadow collections to a ShadowContainer using StaticResource. Shows examples with different CornerRadius values and shadow resources like 'NeumorphismConcave' and 'NeumorphismRaising'.
```XAML
Background="{StaticResource UnoColor}"
BorderBrush="{StaticResource UnoColor}"
Content="Circular"
CornerRadius="40"
Foreground="White" />
```
--------------------------------
### Declare Uno Toolkit XAML Namespace
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/ancestor-itemscontrol-binding.md
Includes the necessary XAML namespace declaration to use the Uno Toolkit UI markup extensions like ItemsControlBinding and AncestorBinding in XAML. This is a repeat of the namespace declaration for context before the second XAML example.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
```
--------------------------------
### Create New Uno App with Material Toolkit - Bash
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/material-getting-started.md
Creates a new Uno Platform application named 'MaterialToolkitApp' with the Material theme and Toolkit features enabled using the .NET CLI.
```bash
dotnet new unoapp -o MaterialToolkitApp -toolkit -theme material
```
--------------------------------
### Initialize MaterialToolkitTheme in App.xaml - XML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/material-getting-started.md
Initializes the `MaterialToolkitTheme` resource dictionary by merging it into the application's resources in `App.xaml`. This also handles the initialization of the base Uno Material resources.
```xml
```
--------------------------------
### Applying Responsive Background with ResponsiveExtension (XML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/responsive-extension.md
Demonstrates using the ResponsiveExtension directly on a property like Background to apply different values (Red, Blue) based on the default Narrow and Wide breakpoints provided by Uno.Toolkit.UI. Requires the 'utu' namespace alias.
```xml
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Using ResponsiveView with Templates (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ResponsiveView.md
Demonstrates the basic usage of Uno.Toolkit.UI.ResponsiveView by defining NarrowTemplate and WideTemplate to display different content based on the current layout breakpoint.
```XML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Specify Platforms for ExtendedSplashScreen (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ExtendedSplashScreen.md
This XAML snippet demonstrates how to configure the ExtendedSplashScreen to be active only on specific platforms by setting the 'Platforms' property. In this example, the splash screen is enabled exclusively for Android and iOS.
```XAML
```
--------------------------------
### Initialize Material Toolkit with C# Markup
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/material-getting-started.md
Initializes the Uno Material Toolkit in App.xaml.cs using the UseMaterialToolkit extension method provided by the Uno.Toolkit.WinUI.Material.Markup package, optionally including color and font overrides.
```C#
using Uno.Toolkit.UI.Material.Markup;
this.Build(r => r.UseMaterialToolkit(
//optional
new Styles.ColorPaletteOverride(),
//optional
new Styles.MaterialFontsOverride()
));
```
--------------------------------
### Configure Segmented TabBar Styles - XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/TabBarAndTabBarItem.md
Provides examples for using 'SegmentedStyle' and 'SlidingSegmentedStyle' with TabBar, which are designed to emulate the appearance and behavior of a native iOS UISegmentedControl. These styles are suitable for selecting between a small number of options.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Setting Theme for XamlRoot using SystemThemeHelper (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/SystemThemeHelper.md
Illustrates how to set the theme for a specific XamlRoot to a particular ElementTheme (e.g., Light) using the SetApplicationTheme method of SystemThemeHelper. Requires a XamlRoot instance.
```csharp
var xamlRoot = someElement.XamlRoot;
SystemThemeHelper.SetApplicationTheme(xamlRoot, ElementTheme.Light);
Console.WriteLine("XamlRoot theme set to Light Mode.");
```
--------------------------------
### Basic DrawerFlyoutPresenter Usage (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/DrawerFlyoutPresenter.md
Shows how to use a Flyout with Placement="Full" and apply a predefined style like BottomDrawerFlyoutPresenterStyle to create a drawer flyout. Includes a basic content structure and VisibleBoundsPadding for safe area handling.
```xml
```
--------------------------------
### Add Uno Features in Project File - XML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/material-getting-started.md
Adds 'Toolkit' and 'Material' to the list of enabled Uno Features within the `.csproj` file of an existing Uno Platform single project.
```xml
Toolkit;Material
```
--------------------------------
### Add MaterialToolkitTheme to App.xaml (Shared Project Legacy)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/material-getting-started.md
Adds the Material Toolkit theme resources and standard WinUI resources to the application's resource dictionary in the legacy shared project template.
```XML
```
--------------------------------
### Using ResponsiveExtension with Static Resources (UWP Workaround)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/responsive-extension.md
Provides a workaround for the UWP-desktop limitation when using ResponsiveExtension. Instead of direct string values, define resources (like SolidColorBrush) and reference them using StaticResource within the ResponsiveExtension. This allows the extension to function correctly on UWP for Windows.
```XAML
RedBlueBrush
...
```
--------------------------------
### Add MaterialToolkitTheme to AppResources.xaml (Multi-Head Legacy)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/material-getting-started.md
Adds the Material Toolkit theme resources to the application's resource dictionary in the App Code Library project for the legacy multi-head template.
```XML
```
--------------------------------
### Loading Font from Android Asset (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples/Platforms/Android/Assets/AboutAssets.txt
Shows how to load a font file from the 'Assets' directory using the Android Typeface.CreateFromAsset method.
```C#
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
```
--------------------------------
### Retrieving Application Theme for XamlRoot using SystemThemeHelper (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/SystemThemeHelper.md
Shows how to retrieve the application theme for a specific XamlRoot using the GetRootTheme method of SystemThemeHelper. It requires a XamlRoot instance, typically obtained from a UI element.
```csharp
var xamlRoot = someElement.XamlRoot;
var appTheme = SystemThemeHelper.GetRootTheme(xamlRoot);
Console.WriteLine($"Current App Theme: {appTheme}");
```
--------------------------------
### Applying Shadows with ShadowContainer in XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ShadowContainer.md
This XAML snippet demonstrates how to use the Uno.Toolkit.UI.ShadowContainer to apply shadows to UI elements. It shows defining a ShadowCollection in Page.Resources for reuse and applying shadows directly within a ShadowContainer. It includes examples for a StackPanel and Button controls.
```xml
xmlns:utu="using:Uno.Toolkit.UI"
...
#7a67f8#f85977
```
--------------------------------
### Initializing ExtendedSplashScreen on Android (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ExtendedSplashScreen.md
This C# snippet demonstrates the required initialization step for the Uno.Toolkit.UI.ExtendedSplashScreen specifically on Android. It calls ExtendedSplashScreen.Init(this) within the MainActivity's OnCreate method to handle the splash screen transition correctly on the Android platform.
```C#
protected override void OnCreate(Bundle bundle)
{
// Handle the splash screen transition.
Uno.Toolkit.UI.ExtendedSplashScreen.Init(this);
base.OnCreate(bundle);
}
```
--------------------------------
### Use ItemsControlBinding and AncestorBinding in Nested Templates (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/ancestor-itemscontrol-binding.md
Provides a comprehensive example demonstrating the use of both ItemsControlBinding and AncestorBinding within nested templates. It shows how to bind to the current item's DataContext, the parent ItemsControl's DataContext, a property on the parent ItemsControl, and a property on a higher-level ancestor (a Page).
```XAML
```
--------------------------------
### Using ResponsiveExtension with Direct Values (UWP Limitation)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/responsive-extension.md
Demonstrates the basic usage of the ResponsiveExtension markup extension to set a property (Background) based on screen size (Narrow, Wide) using direct string values. Note that this specific syntax does not work on UWP projects targeting Windows due to platform limitations.
```XAML
```
--------------------------------
### Reading Raw Android Asset File (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples/Platforms/Android/Assets/AboutAssets.txt
Demonstrates how to open a raw asset file placed in the 'Assets' directory using Android's AssetManager within an Activity's OnCreate method.
```C#
public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
InputStream input = Assets.Open ("my_asset.txt");
}
}
```
--------------------------------
### Basic Usage of DrawerControl in XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/DrawerControl.md
Demonstrates the basic structure for using the DrawerControl in XAML. It shows how to define the main Content and the DrawerContent using nested elements. It also includes the necessary namespace declarations.
```XAML
xmlns:toolkit="using:Uno.UI.Toolkit"
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Using Custom ResponsiveLayout Thresholds (XML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/responsive-extension.md
Shows how to define a custom ResponsiveLayout resource with specific pixel thresholds (400 for Narrow, 800 for Wide) within Page.Resources. This custom layout is then referenced by the ResponsiveExtension using the Layout property to control the breakpoint behavior.
```xml
xmlns:utu="using:Uno.Toolkit.UI"
...
...
```
--------------------------------
### Using FlipViewExtensions Attached Properties for Navigation (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/FlipView-extensions.md
This snippet demonstrates how to use the FlipViewExtensions.Previous and FlipViewExtensions.Next attached properties on Button controls to programmatically navigate a FlipView. It shows a basic FlipView with items and two buttons configured to control its navigation.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Use TabBar Control XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/TabBarAndTabBarItem.md
Illustrates different ways to declare and populate the TabBar control within XAML. It shows how to include the necessary namespace and how to add items directly as content or explicitly within the TabBar.Items property.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
-or-
oneOrMoreItems
-or-
oneOrMoreItems
```
--------------------------------
### Applying Style and Overriding Resources for Uno Toolkit Chip (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/lightweight-styling.md
This snippet shows how to apply a predefined style (`FilterChipStyle`) to an `utu:Chip` control and how to override specific lightweight styling resources (Foreground, Background, BorderBrush) directly within the control's `Resources` collection.
```XAML
```
--------------------------------
### AsyncCommand Implementing ILoadable (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/LoadingView.md
This C# class `AsyncCommand` provides a reusable implementation of `ICommand` that also implements the `ILoadable` interface. It wraps an asynchronous `Task` function and exposes an `IsExecuting` property and `IsExecutingChanged` event, which are required by `ILoadable`. This allows the `LoadingView` control to automatically track the command's execution state and display loading content accordingly.
```csharp
public class AsyncCommand : ICommand, ILoadable
{
public event EventHandler CanExecuteChanged;
public event EventHandler IsExecutingChanged;
private Func _executeAsync;
private bool _isExecuting;
public AsyncCommand(Func executeAsync)
{
_executeAsync = executeAsync;
}
public bool CanExecute(object parameter) => !IsExecuting;
public bool IsExecuting
{
get => _isExecuting;
set
{
if (_isExecuting != value)
{
_isExecuting = value;
IsExecutingChanged?.Invoke(this, new());
CanExecuteChanged?.Invoke(this, new());
}
}
}
public async void Execute(object parameter)
{
try
{
IsExecuting = true;
await _executeAsync();
}
finally
{
IsExecuting = false;
}
}
}
```
--------------------------------
### Defining the ZoomContentControl Class (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ZoomContentControl.md
Shows the basic class definition for the ZoomContentControl, inheriting from Control.
```csharp
public partial class ZoomContentControl : Control
```
--------------------------------
### Overriding Lightweight Styling Resources for Uno Toolkit Chip States (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/lightweight-styling.md
This snippet illustrates how to customize the appearance of an `utu:Chip` control for its default state and the `PointerOver` state by overriding specific lightweight styling resource keys like `ChipForeground`, `ChipBackground`, `ChipBorderBrush`, and their `PointerOver` variants.
```XAML
```
--------------------------------
### Referencing and Using NavigationBar (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/NavigationBar.md
Demonstrates how to declare the Uno Toolkit UI namespace (utu) in XAML and use the NavigationBar control within the markup.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Defining Application Shell with ExtendedSplashScreen (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ExtendedSplashScreen.md
This XAML snippet defines a UserControl named Shell that utilizes the Uno.Toolkit.UI.ExtendedSplashScreen. It sets up the LoadingContent for the splash screen display and the Content property to host the main application frame (ShellFrame). This control serves as the main shell for the application content.
```XML
```
--------------------------------
### Using the Chip Control (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ChipAndChipGroup.md
Demonstrates the XAML namespace declaration required to use Uno Toolkit UI controls and a basic placeholder for the Chip element within a XAML page or control.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Using Command Extensions in XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/command-extensions.md
This XAML snippet demonstrates how to apply the `utu:CommandExtensions.Command` attached property to different controls like `PasswordBox`, `ListView`, `NavigationView`, and `ItemsRepeater` to bind their default interaction events to commands.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
```
--------------------------------
### Applying ResourceExtensions.Resources to Button Style (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/helpers/resource-extensions.md
This XAML snippet demonstrates how to use the ResourceExtensions.Resources attached property within a Style definition for a Button. It shows how to embed a ResourceDictionary directly into the style setter, including theme dictionaries for 'Default' and 'Light' themes, overriding specific resource keys like FilledButtonForeground and FilledButtonBackground.
```XAML
```
--------------------------------
### Setting Custom Background for DrawerFlyoutPresenter (XAML)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/DrawerFlyoutPresenter.md
Shows the recommended way to set a custom Background for the DrawerFlyoutPresenter using a Style based on a predefined drawer style. This avoids edge bleeding and issues with rounded corners.
```xml
```
--------------------------------
### Setting Shell as Root Visual in App.cs (C#)
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/ExtendedSplashScreen.md
This C# snippet shows how to set the custom Shell UserControl as the MainWindow.Content in the App.cs OnLaunched method. It ensures the shell is created if not already present and navigates the internal RootFrame to the initial page (MainPage). This makes the Shell the root visual element of the application window.
```C#
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
// Code ommited for brevity
if (MainWindow.Content is not Shell shell)
{
shell = new Shell();
MainWindow.Content = shell;
shell.RootFrame.NavigationFailed += OnNavigationFailed;
}
if (shell.RootFrame.Content == null)
{
shell.RootFrame.Navigate(typeof(MainPage), args.Arguments);
}
MainWindow.Activate();
}
```
--------------------------------
### Using TabBarItem in XAML
Source: https://github.com/unoplatform/uno.toolkit.ui/blob/main/doc/controls/TabBarAndTabBarItem.md
These XAML snippets demonstrate how to declare a TabBarItem, including adding the necessary namespace and providing content either as an attribute or within the element.
```XAML
xmlns:utu="using:Uno.Toolkit.UI"
...
-or-
content
```