.NET MAUI Samples

repository·main·Indexed 25 days ago

https://github.com/dotnet/maui-samples

A collection of reference implementations and learning resources for .NET Multi-platform App UI (.NET MAUI). It includes samples for building cross-platform apps for Android, iOS, macOS, and Windows using C# and XAML, featuring implementations such as cross-platform age verification via IAgeSignalService and AI integration using IChatClient from Microsoft.Extensions.AI.

Tokens
28.5K
Snippets
36
Records
214
Agent score
84%

What's inside dotnet-maui-samples

  1. Overview of the Point of Sale Demo App

    main

    The Point of Sale application is a .NET MAUI demo designed to showcase UI techniques for building adaptive desktop, tablet, and mobile applications from a single codebase. Key features demonstrated include:

    • Customizing sidebar menus
    • Implementing tab bars
    • Using radio buttons
    • Adapting UI to different device form factors (Desktop/Tablet vs. Mobile)

    Note: This is a demonstration project and not a complete, production-ready application.

  2. Overview of Age Signals Sample

    main

    The Age Signals sample is a .NET MAUI application that demonstrates how to implement cross-platform age verification using platform-specific APIs. It provides a unified interface (IAgeSignalService) to interact with:

    • Android: Google Play Age Signals (API 23+)
    • iOS: Declared Age Range (iOS 26.0+)
    • Windows: Age Consent API (Windows 11 Build 22000+)

    Note: Mac Catalyst is not supported because the Apple DeclaredAgeRange framework is unavailable for Mac Catalyst targets.

  3. Overview of Solitaire Encryption .NET MAUI Sample

    main
    The Solitaire Encryption sample is a C# port of the encryption algorithm featured in Neal Stephenson's novel Cryptonomicon. It is implemented as a .NET MAUI application targeting iOS, Android, Windows, and macOS. The project also includes an xUnit test project containing tests derived from the author's website. The algorithm is based on a deck of cards, though this implementation abstracts that complexity within the UI.
  4. Overview of the BugSweeper sample

    main

    BugSweeper is a .NET MAUI implementation of a classic grid-based game. The game features a 9-by-9 grid of tiles where players must find and flag ten hidden bugs to win.

    Gameplay Mechanics

    • Starting the game: Double-tap any tile to begin. The first double-tap is guaranteed to be safe.
    • Tile indicators: After the first move, numbers displayed on tiles indicate how many surrounding tiles contain bugs.
    • Flagging bugs: Use a single tap on a tile to flag (or unflag) a suspected bug.
    • Losing the game: Avoid double-tapping a tile that contains a bug.
  5. Overview of the TipCalc sample

    main

    TipCalc is a .NET MAUI sample application that demonstrates how to build a tip calculator using XAML and data-binding. It allows users to input a food-and-drink subtotal and a post-tax total, then select a tip percentage. The application calculates the tip based on the subtotal and adds it to the post-tax total, rounding the final result to the nearest quarter.

    Key technical features demonstrated:

    • UI Definition: Uses XAML in TipCalcPage.xaml.
    • Logic/Data Model: Calculations are encapsulated in a TipCalcModel class.
    • Data Binding: Utilizes data-binding and two custom value converters to manage data flow between the model and the UI.
    • Cross-Platform Support: Builds for iOS, Android, Windows, and Mac Catalyst.
  6. Overview of BillingService Sample

    main

    The BillingService sample demonstrates how to implement cross-platform in-app purchases in a .NET MAUI application using an MVVM architecture. It provides a unified interface to interact with platform-specific billing systems:

    • Android: Google Play Billing Client v7
    • iOS & Mac Catalyst: Apple StoreKit 1
    • Windows: Microsoft Store APIs

    The sample covers product discovery, secure purchase flows, purchase restoration, and ownership verification.

  7. Use Brushes to paint areas in .NET MAUI

    main

    In .NET MAUI, you can use the Brush class to paint an area, such as the background of a control. Brush is an abstract class, and you use its derived classes to define different painting styles.

    Available brush types include:

    • SolidColorBrush: Paints an area with a single solid color.
    • LinearGradientBrush: Paints an area using a linear gradient.
    • RadialGradientBrush: Paints an area using a radial gradient.