### Platform-Specific Appium Setup Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UITesting/BasicAppiumNunitSample/README.md Contains platform-specific details and configurations for Appium tests. Each class includes inline comments to describe the setup for Android, iOS, macOS, and Windows. ```csharp public class AppiumSetup { // Platform-specific Appium setup code } ``` -------------------------------- ### Platform-Specific Appium Setup Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UITesting/BasicAppiumNunitSample/README.md Contains platform-specific details and configurations for Appium tests. Each class includes inline comments to describe the setup for Android, iOS, macOS, and Windows. ```csharp public class AppiumSetup { // Platform-specific Appium setup code } ``` -------------------------------- ### Map Control Setup Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/Views/Map/README.md This snippet shows the basic setup for using the Map control in .NET MAUI, including the necessary NuGet package and platform-specific configuration for Android. ```csharp // Add the Microsoft.Maui.Controls.Maps NuGet package // For Android, obtain a Google Maps API key and insert it into the AndroidManifest.xml file. // See: https://learn.microsoft.com/dotnet/maui/user-interface/controls/map#get-a-google-maps-api-key ``` ```xaml ``` -------------------------------- ### .NET MAUI Shell Navigation Example Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/Apps/WhatToEat/README.md Demonstrates navigation patterns and route management using .NET MAUI Shell. This sample highlights how to structure an application for intuitive user experience. ```csharp // Example of Shell navigation setup (conceptual) // In a real MAUI app, this would be in AppShell.xaml or related code-behind. public partial class AppShell : Shell { public AppShell() { InitializeComponent(); // Define routes and navigation logic here } } ``` ```xaml ``` -------------------------------- ### Map Control Setup Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/Views/Map/README.md This snippet shows the basic setup for using the Map control in .NET MAUI, including the necessary NuGet package and platform-specific configuration for Android. ```csharp // Add the Microsoft.Maui.Controls.Maps NuGet package // For Android, obtain a Google Maps API key and insert it into the AndroidManifest.xml file. // See: https://learn.microsoft.com/dotnet/maui/user-interface/controls/map#get-a-google-maps-api-key ``` ```xaml ``` -------------------------------- ### .NET MAUI Shell Navigation Example Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/Apps/WhatToEat/README.md Demonstrates navigation patterns and route management using .NET MAUI Shell. This sample highlights how to structure an application for intuitive user experience. ```csharp // Example of Shell navigation setup (conceptual) // In a real MAUI app, this would be in AppShell.xaml or related code-behind. public partial class AppShell : Shell { public AppShell() { InitializeComponent(); // Define routes and navigation logic here } } ``` ```xaml ``` -------------------------------- ### .NET MAUI FlyoutPage Navigation Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/Navigation/FlyoutPageSample/README.md This C# code demonstrates the setup and navigation logic for a FlyoutPage in .NET MAUI. It typically involves setting up the main page and the flyout content, and handling navigation events. ```csharp public partial class MainPage : FlyoutPage { public MainPage() { InitializeComponent(); } } ``` -------------------------------- ### .NET MAUI FlyoutPage Navigation Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/Navigation/FlyoutPageSample/README.md This C# code demonstrates the setup and navigation logic for a FlyoutPage in .NET MAUI. It typically involves setting up the main page and the flyout content, and handling navigation events. ```csharp public partial class MainPage : FlyoutPage { public MainPage() { InitializeComponent(); } } ``` -------------------------------- ### HybridWebView Communication Example Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/Views/HybridWebViewDemo/README.md This snippet illustrates how to set up and use the HybridWebView in .NET MAUI to facilitate communication between JavaScript in the web view and C# code in the application. It covers basic setup and message passing. ```csharp public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); // Set the source for the HybridWebView hybridWebView.Source = new HtmlWebViewSource { Html = "

Hello from MAUI!

", BaseUrl = BaseUrl.CreateOptions() }; // Register a JavaScript function to be callable from C# hybridWebView.RegisterAction(async () => await DisplayAlert("Alert", "JavaScript function called!", "OK")); } // Method to be called from JavaScript public void InvokeCSharpAction() { // This method will be called when the button in the HTML is clicked // You can add your C# logic here } } ``` ```javascript function invokeCSharpAction() { // This function is called from the HTML button click // It invokes the registered C# action window.chrome.webview.postMessage('Hello from JavaScript!'); } ``` ```xaml ``` -------------------------------- ### HybridWebView Communication Example Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/Views/HybridWebViewDemo/README.md This snippet illustrates how to set up and use the HybridWebView in .NET MAUI to facilitate communication between JavaScript in the web view and C# code in the application. It covers basic setup and message passing. ```csharp public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); // Set the source for the HybridWebView hybridWebView.Source = new HtmlWebViewSource { Html = "

Hello from MAUI!

", BaseUrl = BaseUrl.CreateOptions() }; // Register a JavaScript function to be callable from C# hybridWebView.RegisterAction(async () => await DisplayAlert("Alert", "JavaScript function called!", "OK")); } // Method to be called from JavaScript public void InvokeCSharpAction() { // This method will be called when the button in the HTML is clicked // You can add your C# logic here } } ``` ```javascript function invokeCSharpAction() { // This function is called from the HTML button click // It invokes the registered C# action window.chrome.webview.postMessage('Hello from JavaScript!'); } ``` ```xaml ``` -------------------------------- ### Theming with ResourceDictionaries and DynamicResource Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/ThemingDemo/README.md This snippet illustrates the core concept of theming in .NET MAUI. It involves defining separate ResourceDictionaries for each theme and using the DynamicResource markup extension to apply styles dynamically. This allows for runtime theme switching. ```csharp public partial class App : Application { public App() { InitializeComponent(); // Load the default theme Application.Current.Resources.MergedDictionaries.Add(new LightTheme()); MainPage = new NavigationPage(new ThemingPage()); } } ``` ```xaml ``` ```xaml Blue White ``` ```xaml White Black ``` -------------------------------- ### BrowserStack .NET SDK Setup for Apple Silicon Macs Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UITesting/BrowserStackAppiumMaui/README.md Installs and sets up the BrowserStack .NET SDK for macOS environments with Apple Silicon chips, ensuring compatibility for .NET toolchain. ```bash dotnet tool install browserstack-sdk --version 1.16.3 --create-manifest-if-needed dotnet browserstack-sdk setup-dotnet --dotnet-path "." --dotnet-version "8.0.403" --yes ``` -------------------------------- ### Theming with ResourceDictionaries and DynamicResource Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/ThemingDemo/README.md This snippet illustrates the core concept of theming in .NET MAUI. It involves defining separate ResourceDictionaries for each theme and using the DynamicResource markup extension to apply styles dynamically. This allows for runtime theme switching. ```csharp public partial class App : Application { public App() { InitializeComponent(); // Load the default theme Application.Current.Resources.MergedDictionaries.Add(new LightTheme()); MainPage = new NavigationPage(new ThemingPage()); } } ``` ```xaml ``` ```xaml Blue White ``` ```xaml White Black ``` -------------------------------- ### BrowserStack .NET SDK Setup for Apple Silicon Macs Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UITesting/BrowserStackAppiumMaui/README.md Installs and sets up the BrowserStack .NET SDK for macOS environments with Apple Silicon chips, ensuring compatibility for .NET toolchain. ```bash dotnet tool install browserstack-sdk --version 1.16.3 --create-manifest-if-needed dotnet browserstack-sdk setup-dotnet --dotnet-path "." --dotnet-version "8.0.403" --yes ``` -------------------------------- ### AppiumServerHelper.cs - Shared Test Code Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UITesting/BrowserStackAppiumMaui/BasicAppiumNunitSample/README.md This C# code snippet is part of the UITests.Shared project and contains the AppiumServerHelper class. This class is responsible for starting and stopping the Appium server as part of the test execution process, simplifying the test setup. ```csharp using System; using System.Diagnostics; using System.IO; using System.Threading; using NUnit.Framework; namespace UITests.Shared { public static class AppiumServerHelper { private static Process _appiumProcess; public static void StartAppiumServer() { // Ensure Appium is installed and in PATH, or provide the full path to appium.cmd string appiumPath = "appium"; // Assumes appium is in PATH string arguments = "--base-path /wd/hub --port 4723"; // Example arguments var startInfo = new ProcessStartInfo { FileName = appiumPath, Arguments = arguments, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true }; try { _appiumProcess = Process.Start(startInfo); // Give the server a moment to start up Thread.Sleep(10000); // Adjust as needed if (_appiumProcess.HasExited) { string errorOutput = _appiumProcess.StandardError.ReadToEnd(); throw new Exception($"Appium server failed to start. Error: {errorOutput}"); } } catch (Exception ex) { throw new Exception($"Failed to start Appium server: {ex.Message}"); } } public static void StopAppiumServer() { if (_appiumProcess != null && !_appiumProcess.HasExited) { try { _appiumProcess.Kill(); _appiumProcess.WaitForExit(); } catch (Exception ex) { Console.WriteLine($"Error stopping Appium server: {ex.Message}"); } } } } } ``` -------------------------------- ### AppiumServerHelper.cs - Shared Test Code Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UITesting/BrowserStackAppiumMaui/BasicAppiumNunitSample/README.md This C# code snippet is part of the UITests.Shared project and contains the AppiumServerHelper class. This class is responsible for starting and stopping the Appium server as part of the test execution process, simplifying the test setup. ```csharp using System; using System.Diagnostics; using System.IO; using System.Threading; using NUnit.Framework; namespace UITests.Shared { public static class AppiumServerHelper { private static Process _appiumProcess; public static void StartAppiumServer() { // Ensure Appium is installed and in PATH, or provide the full path to appium.cmd string appiumPath = "appium"; // Assumes appium is in PATH string arguments = "--base-path /wd/hub --port 4723"; // Example arguments var startInfo = new ProcessStartInfo { FileName = appiumPath, Arguments = arguments, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true }; try { _appiumProcess = Process.Start(startInfo); // Give the server a moment to start up Thread.Sleep(10000); // Adjust as needed if (_appiumProcess.HasExited) { string errorOutput = _appiumProcess.StandardError.ReadToEnd(); throw new Exception($"Appium server failed to start. Error: {errorOutput}"); } } catch (Exception ex) { throw new Exception($"Failed to start Appium server: {ex.Message}"); } } public static void StopAppiumServer() { if (_appiumProcess != null && !_appiumProcess.HasExited) { try { _appiumProcess.Kill(); _appiumProcess.WaitForExit(); } catch (Exception ex) { Console.WriteLine($"Error stopping Appium server: {ex.Message}"); } } } } } ``` -------------------------------- ### Build SamplePackage Project Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/Packaging/NuGetWithMSBuildFiles/README.md Command to build the SamplePackage project, which automatically generates the NuGet package. ```cli dotnet build src/SamplePackage/SamplePackage.csproj ``` -------------------------------- ### Install Appium and Drivers Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UITesting/BrowserStackAppiumMaui/README.md Installs Appium and the necessary drivers (XCUITest for iOS, UIAutomator2 for Android) required for building and running Appium tests. ```bash npm install -g appium # For Android appium driver install uiautomator2 # For iOS appium driver install xcuitest ``` -------------------------------- ### Build SamplePackage Project Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/Packaging/NuGetWithMSBuildFiles/README.md Command to build the SamplePackage project, which automatically generates the NuGet package. ```cli dotnet build src/SamplePackage/SamplePackage.csproj ``` -------------------------------- ### Install Appium and Drivers Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UITesting/BrowserStackAppiumMaui/README.md Installs Appium and the necessary drivers (XCUITest for iOS, UIAutomator2 for Android) required for building and running Appium tests. ```bash npm install -g appium # For Android appium driver install uiautomator2 # For iOS appium driver install xcuitest ``` -------------------------------- ### SamplePackage Project Configuration Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/Packaging/NuGetWithMSBuildFiles/README.md XML configuration for the SamplePackage .csproj file, including package metadata and output path. ```xml 0.0.99999-sample ../artifacts/ true ``` -------------------------------- ### SamplePackage Project Configuration Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/Packaging/NuGetWithMSBuildFiles/README.md XML configuration for the SamplePackage .csproj file, including package metadata and output path. ```xml 0.0.99999-sample ../artifacts/ true ``` -------------------------------- ### .NET MAUI Media Namespace Features Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/PlatformIntegration/PlatformIntegrationDemos/README.md Demonstrates features within the Microsoft.Maui.Media namespace, including media picking, taking screenshots, and text-to-speech conversion. ```csharp // Example for Media Picker (Image) // var result = await MediaPicker.PickPhotoAsync(); // if (result != null) { var stream = await result.OpenReadAsync(); } // Example for Screenshot // var screenshot = await Screenshot.Default.CaptureAsync(); // var stream = await screenshot.OpenReadAsync(); // Example for Text-to-Speech // await TextToSpeech.Default.SpeakAsync("Hello from MAUI"); // Example for Unit Converters (Conceptual - MAUI doesn't have a direct unit converter API, this is illustrative) // double celsius = 25; // double fahrenheit = (celsius * 9 / 5) + 32; ``` -------------------------------- ### RadialGradientBrush Example Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/BrushesDemos/README.md Shows how to use a RadialGradientBrush to paint an area with a gradient that radiates outwards from a central point. ```csharp var radialGradientBrush = new RadialGradientBrush { Center = new Point(0.5, 0.5), Radius = 0.75, GradientStops = new GradientStopCollection { new GradientStop(Colors.Yellow, 0.0f), new GradientStop(Colors.Orange, 1.0f) } }; // Apply this brush to a control's background. ``` ```xaml ``` -------------------------------- ### .NET MAUI Media Namespace Features Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/PlatformIntegration/PlatformIntegrationDemos/README.md Demonstrates features within the Microsoft.Maui.Media namespace, including media picking, taking screenshots, and text-to-speech conversion. ```csharp // Example for Media Picker (Image) // var result = await MediaPicker.PickPhotoAsync(); // if (result != null) { var stream = await result.OpenReadAsync(); } // Example for Screenshot // var screenshot = await Screenshot.Default.CaptureAsync(); // var stream = await screenshot.OpenReadAsync(); // Example for Text-to-Speech // await TextToSpeech.Default.SpeakAsync("Hello from MAUI"); // Example for Unit Converters (Conceptual - MAUI doesn't have a direct unit converter API, this is illustrative) // double celsius = 25; // double fahrenheit = (celsius * 9 / 5) + 32; ``` -------------------------------- ### RadialGradientBrush Example Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/BrushesDemos/README.md Shows how to use a RadialGradientBrush to paint an area with a gradient that radiates outwards from a central point. ```csharp var radialGradientBrush = new RadialGradientBrush { Center = new Point(0.5, 0.5), Radius = 0.75, GradientStops = new GradientStopCollection { new GradientStop(Colors.Yellow, 0.0f), new GradientStop(Colors.Orange, 1.0f) } }; // Apply this brush to a control's background. ``` ```xaml ``` -------------------------------- ### MAUI Sample Dependencies Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/Apps/PointOfSale/README.md This section lists the key libraries and tools used in the Point of Sale MAUI sample, including CommunityToolkit.Mvvm for MVVM patterns, CommunityToolkit.Maui for MAUI extensions, SkiaSharp for graphics, MicroCharts for charting, and Ril.BlazorSignatureCanvas for signature input. ```text CommunityToolkit.Mvvm: https://learn.microsoft.com/windows/communitytoolkit/mvvm/introduction CommunityToolkit.Maui: https://github.com/CommunityToolkit/Maui SkiaSharp & Lottie: https://mono.github.io/SkiaSharp.Extended/api/ui-maui/#sklottieview MicroCharts: https://github.com/microcharts-dotnet/Microcharts Ril.BlazorSignatureCanvas: https://github.com/ResourceWare/Ril.BlazorSignatureCanvas ``` -------------------------------- ### Label Hyperlink Example Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/HyperlinkDemo/README.md Shows how to create a hyperlink using a Label control with text decorations and a TapGestureRecognizer in .NET MAUI. ```csharp var label = new Label { Text = "Visit Microsoft", TextDecorations = TextDecorations.Underline }; var tapGesture = new TapGestureRecognizer(); tapGesture.Tapped += (s, e) => { // Handle hyperlink tap Launcher.OpenAsync(new Uri("https://www.microsoft.com")); }; label.GestureRecognizers.Add(tapGesture); ``` ```xaml ``` -------------------------------- ### LinearGradientBrush Example Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/BrushesDemos/README.md Illustrates the use of a LinearGradientBrush to paint an area with a gradient transitioning between two or more colors along a specified direction. ```csharp var linearGradientBrush = new LinearGradientBrush { StartPoint = new Point(0, 0), EndPoint = new Point(1, 1), GradientStops = new GradientStopCollection { new GradientStop(Colors.Blue, 0.0f), new GradientStop(Colors.Green, 1.0f) } }; // Apply this brush to a control's background. ``` ```xaml ``` -------------------------------- ### MAUI Sample Dependencies Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/Apps/PointOfSale/README.md This section lists the key libraries and tools used in the Point of Sale MAUI sample, including CommunityToolkit.Mvvm for MVVM patterns, CommunityToolkit.Maui for MAUI extensions, SkiaSharp for graphics, MicroCharts for charting, and Ril.BlazorSignatureCanvas for signature input. ```text CommunityToolkit.Mvvm: https://learn.microsoft.com/windows/communitytoolkit/mvvm/introduction CommunityToolkit.Maui: https://github.com/CommunityToolkit/Maui SkiaSharp & Lottie: https://mono.github.io/SkiaSharp.Extended/api/ui-maui/#sklottieview MicroCharts: https://github.com/microcharts-dotnet/Microcharts Ril.BlazorSignatureCanvas: https://github.com/ResourceWare/Ril.BlazorSignatureCanvas ``` -------------------------------- ### SolidColorBrush Example Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/BrushesDemos/README.md Demonstrates how to use a SolidColorBrush to paint an area with a single color. This is a fundamental brush type in .NET MAUI. ```csharp var solidColorBrush = new SolidColorBrush(Colors.Red); // Apply this brush to a control's background, for example: // myControl.Background = solidColorBrush; ``` ```xaml ``` -------------------------------- ### Label Hyperlink Example Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/HyperlinkDemo/README.md Shows how to create a hyperlink using a Label control with text decorations and a TapGestureRecognizer in .NET MAUI. ```csharp var label = new Label { Text = "Visit Microsoft", TextDecorations = TextDecorations.Underline }; var tapGesture = new TapGestureRecognizer(); tapGesture.Tapped += (s, e) => { // Handle hyperlink tap Launcher.OpenAsync(new Uri("https://www.microsoft.com")); }; label.GestureRecognizers.Add(tapGesture); ``` ```xaml ``` -------------------------------- ### .NET MAUI ListView Basic Usage Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/Views/ListViewDemos/README.md This snippet demonstrates the fundamental setup of a .NET MAUI ListView, including its data binding and item template definition. It relies on the MAUI framework and requires a `DataTemplate` to define the appearance of each list item. ```csharp public partial class ListViewPage : ContentPage { public ListViewPage() { InitializeComponent(); var items = new List { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; MyListView.ItemsSource = items; } } ``` ```xaml ``` -------------------------------- ### SolidColorBrush Example Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/BrushesDemos/README.md Demonstrates how to use a SolidColorBrush to paint an area with a single color. This is a fundamental brush type in .NET MAUI. ```csharp var solidColorBrush = new SolidColorBrush(Colors.Red); // Apply this brush to a control's background, for example: // myControl.Background = solidColorBrush; ``` ```xaml ``` -------------------------------- ### .NET MAUI ListView Basic Usage Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/Views/ListViewDemos/README.md This snippet demonstrates the fundamental setup of a .NET MAUI ListView, including its data binding and item template definition. It relies on the MAUI framework and requires a `DataTemplate` to define the appearance of each list item. ```csharp public partial class ListViewPage : ContentPage { public ListViewPage() { InitializeComponent(); var items = new List { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; MyListView.ItemsSource = items; } } ``` ```xaml ``` -------------------------------- ### LinearGradientBrush Example Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/BrushesDemos/README.md Illustrates the use of a LinearGradientBrush to paint an area with a gradient transitioning between two or more colors along a specified direction. ```csharp var linearGradientBrush = new LinearGradientBrush { StartPoint = new Point(0, 0), EndPoint = new Point(1, 1), GradientStops = new GradientStopCollection { new GradientStop(Colors.Blue, 0.0f), new GradientStop(Colors.Green, 1.0f) } }; // Apply this brush to a control's background. ``` ```xaml ``` -------------------------------- ### Package Consumer App Reference Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/Packaging/NuGetWithMSBuildFiles/README.md XML configuration for the PackageConsumerApp .csproj, referencing the SamplePackage NuGet package. ```xml ``` -------------------------------- ### Span Hyperlink Example Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/HyperlinkDemo/README.md Demonstrates creating a hyperlink within a larger text block using a Span control with text decorations and a TapGestureRecognizer in .NET MAUI. ```csharp var formattedString = new FormattedString(); formattedString.Spans.Add(new Span { Text = "For more information, ", TextColor = Colors.Black }); formattedString.Spans.Add(new Span { Text = "visit Microsoft.", TextColor = Colors.Blue, TextDecorations = TextDecorations.Underline, GestureRecognizers = { new TapGestureRecognizer { Tapped += (s, e) => { Launcher.OpenAsync(new Uri("https://www.microsoft.com")); } } } }); var label = new Label { FormattedText = formattedString }; ``` ```xaml ``` -------------------------------- ### Package References in SamplePackage Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/Packaging/NuGetWithMSBuildFiles/README.md XML configuration for package references in the SamplePackage .csproj, including SourceLink and System.Management. ```xml ``` -------------------------------- ### Span Hyperlink Example Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/UserInterface/HyperlinkDemo/README.md Demonstrates creating a hyperlink within a larger text block using a Span control with text decorations and a TapGestureRecognizer in .NET MAUI. ```csharp var formattedString = new FormattedString(); formattedString.Spans.Add(new Span { Text = "For more information, ", TextColor = Colors.Black }); formattedString.Spans.Add(new Span { Text = "visit Microsoft.", TextColor = Colors.Blue, TextDecorations = TextDecorations.Underline, GestureRecognizers = { new TapGestureRecognizer { Tapped += (s, e) => { Launcher.OpenAsync(new Uri("https://www.microsoft.com")); } } } }); var label = new Label { FormattedText = formattedString }; ``` ```xaml ``` -------------------------------- ### Package Consumer App Reference Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/Packaging/NuGetWithMSBuildFiles/README.md XML configuration for the PackageConsumerApp .csproj, referencing the SamplePackage NuGet package. ```xml ``` -------------------------------- ### JavaScript Invoking .NET Sync Methods Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/Views/HybridWebViewDemo/HybridWebViewDemo/Resources/Raw/wwwroot/index.html Demonstrates how to invoke synchronous .NET methods from JavaScript using `window.HybridWebView.InvokeDotNet`. Includes examples with and without parameters, and with return values. ```javascript async function InvokeDoSyncWork() { LogMessage("Invoking DoSyncWork"); await window.HybridWebView.InvokeDotNet('DoSyncWork'); LogMessage("Invoked DoSyncWork"); } async function InvokeDoSyncWorkParams() { LogMessage("Invoking DoSyncWorkParams"); await window.HybridWebView.InvokeDotNet('DoSyncWorkParams', [123, 'hello']); LogMessage("Invoked DoSyncWorkParams"); } async function InvokeDoSyncWorkReturn() { LogMessage("Invoking DoSyncWorkReturn"); const retValue = await window.HybridWebView.InvokeDotNet('DoSyncWorkReturn'); LogMessage("Invoked DoSyncWorkReturn, return value: " + retValue); } async function InvokeDoSyncWorkParamsReturn() { LogMessage("Invoking DoSyncWorkParamsReturn"); const retValue = await window.HybridWebView.InvokeDotNet('DoSyncWorkParamsReturn', [123, 'hello']); LogMessage("Invoked DoSyncWorkParamsReturn, return value: message=" + retValue.Message + ", value=" + retValue.Value); } ``` -------------------------------- ### Package References in SamplePackage Source: https://github.com/dotnet/maui-samples.git/blob/main/10.0/Packaging/NuGetWithMSBuildFiles/README.md XML configuration for package references in the SamplePackage .csproj, including SourceLink and System.Management. ```xml ``` -------------------------------- ### JavaScript Invoking .NET Async Methods Source: https://github.com/dotnet/maui-samples.git/blob/main/9.0/UserInterface/Views/HybridWebViewDemo/HybridWebViewDemo/Resources/Raw/wwwroot/index.html Demonstrates how to invoke asynchronous .NET methods from JavaScript using `window.HybridWebView.InvokeDotNet`. Includes examples with and without parameters, and with return values. ```javascript async function InvokeDoAsyncWork() { LogMessage("Invoking DoAsyncWork"); await window.HybridWebView.InvokeDotNet('DoAsyncWork'); LogMessage("Invoked DoAsyncWork"); } async function InvokeDoAsyncWorkParams() { LogMessage("Invoking DoAsyncWorkParams"); await window.HybridWebView.InvokeDotNet('DoAsyncWorkParams', [123, 'hello']); LogMessage("Invoked DoAsyncWorkParams"); } async function InvokeDoAsyncWorkReturn() { LogMessage("Invoking DoAsyncWorkReturn"); const retValue = await window.HybridWebView.InvokeDotNet('DoAsyncWorkReturn'); LogMessage("Invoked DoAsyncWorkReturn, return value: " + retValue); } async function InvokeDoAsyncWorkParamsReturn() { LogMessage("Invoking DoAsyncWorkParamsReturn"); const retValue = await window.HybridWebView.InvokeDotNet('DoAsyncWorkParamsReturn', [123, 'hello']); LogMessage("Invoked DoAsyncWorkParamsReturn, return value: message=" + retValue.Message + ", value=" + retValue.Value); } ```