### Build IHost Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Hosting/HowTo-HostingSetup.md Finalize the setup by building the host and assigning it to the Host property. ```cs protected override void OnLaunched(LaunchActivatedEventArgs e) { var appBuilder = this.CreateBuilder(args) .Configure(host => { // Configure the host builder }); MainWindow = builder.Window; Host = appBuilder.Build(); ... } ``` -------------------------------- ### Install and Run Kiota CLI Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Http/HowTo-Kiota.md Install the global Kiota tool and generate a C# client from an OpenAPI specification. ```bash dotnet tool install --global Microsoft.OpenApi.Kiota ``` ```bash # From a static spec file kiota generate --openapi PATH_TO_YOUR_API_SPEC.json --language CSharp --class-name MyApiClient --namespace-name MyApp.Client.MyApi --output ./MyApp/Content/Client/MyApi # OR directly from the running server’s Swagger endpoint kiota generate --openapi http://localhost:5002/swagger/v1/swagger.json --language CSharp --class-name MyApiClient --namespace-name MyApp.Client.MyApi --output ./MyApp/Content/Client/MyApi ``` -------------------------------- ### Start IHost in OnLaunched Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Hosting/HostingOverview.md Execute host startup within the application launch lifecycle. ```csharp protected override void OnLaunched(LaunchActivatedEventArgs e) { ... await Task.Run(() => Host.StartAsync()); } ``` -------------------------------- ### Install Hosting Feature Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Hosting/HowTo-HostingSetup.md Add the Hosting feature to the UnoFeatures property in your project file. ```diff Material; + Hosting; Toolkit; MVUX; ``` -------------------------------- ### Initialize C# Markup Page Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Markup/HowTo-CustomMarkupProject.md Example of setting up a MainPage using C# markup extensions for layout and data binding. ```csharp using Microsoft.UI; using Microsoft.UI.Text; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; using MySampleProject.Model; using MySampleProject.ViewModel; using System; namespace MySampleProject; public sealed partial class MainPage : Page { public MainPage() { //Create an ViewModel that load a list of samples DataContext = new ViewModelSample(); //Set a ViewModel to the DataContext this.DataContext((page, vm) => page .Background(ThemeResource.Get("ApplicationPageBackgroundThemeBrush")) .Content( new Grid() .Style(GetGridStyle()) .RowDefinitions("Auto, *") .ColumnDefinitions("2*, Auto, 2*") .Background(new SolidColorBrush(Colors.Silver)) .Margin(50) .Children( ``` -------------------------------- ### Configure Authentication Provider Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Authentication/HowTo-Cookies.md Initial setup of the IHostBuilder with a custom authentication provider. ```csharp protected override void OnLaunched(LaunchActivatedEventArgs args) { var builder = this.CreateBuilder(args) .Configure(host => { host.UseAuthentication(auth => auth.AddCustom(custom => custom.Login( async (sp, dispatcher, tokenCache, credentials, cancellationToken) => { var isValid = credentials.TryGetValue("Username", out var username) && username == "Bob"; return isValid ? credentials : default; }) )); }); ... } ``` -------------------------------- ### Create an Uno Platform app with the CLI Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/GettingStarted.md Commands to install the Uno templates and generate a new project using the recommended preset. ```dotnetcli dotnet new install Uno.Templates ``` ```dotnetcli dotnet new unoapp -o MyProject -preset recommended ``` -------------------------------- ### Set Background via XAML Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Markup/HowTo-CreateMarkupProject.md Equivalent XAML examples for setting background using Theme, Colors, and ARGB values. ```xml ``` ```xml ``` ```xml ``` -------------------------------- ### Complete Visibility-Based Navigation Example Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Navigation/Walkthrough/UsePanel.md A full implementation of a page using visibility-based region navigation. ```xml ``` -------------------------------- ### Define a paginated data service Source: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Mvux/Walkthrough/Pagination.howto.md Create an interface and implementation that supports fetching data in chunks based on page size and starting index. ```csharp namespace PaginationPeopleApp; public partial record Person(int Id, string FirstName, string LastName); public interface IPeopleService { ValueTask> GetPeopleAsync( uint pageSize, uint firstItemIndex, CancellationToken ct); } public class PeopleService : IPeopleService { public async ValueTask> GetPeopleAsync( uint pageSize, uint firstItemIndex, CancellationToken ct) { var (size, start) = ((int)pageSize, (int)firstItemIndex); await Task.Delay(TimeSpan.FromSeconds(1), ct); // simulate remote call var all = GetPeople(); // returns a big in-memory list return all .Skip(start) .Take(size) .ToImmutableList(); } } ```