C# Markup Documentation

repository·master·Indexed 21 days ago

https://github.com/vincenth-net/csharpformarkup

A concise, next-generation markup library for .NET UI frameworks including WinUI, WPF, and Uno Platform. C# Markup 2 and 4.0 provide a Flutter-like developer experience by eliminating XAML and reducing verbosity through a fluent API, high-performance expression-based bindings, and a partial class system that separates UI markup from logic. Supports .NET 9 and 10, C# 14, and integrations with LiveCharts2, Mapsui 5, and ScottPlot.NET.

Tokens
6.1K
Snippets
12
Records
31
Agent score
66%

What's inside C# Markup

  1. Overview of C# Markup 2

    master

    C# Markup 2 allows you to build .NET applications fully in C#, eliminating the need for XAML, HTML, JavaScript, or CSS. It provides a Flutter-like UI development experience that leverages .NET Hot Reload.

    This version is designed to target:

    • WinUI 3 (Windows App SDK)
    • Uno Platform (including browser WebAssembly)

    When your application targets Windows only, C# Markup 2 depends only on the Windows App SDK and does not require Uno Platform.

  2. Use C# Markup with Uno.Extensions.Reactive.WinUI

    master
    This package provides the C# Markup 2 API specifically for the Uno.Extensions.Reactive.WinUI NuGet package. It allows you to build user interfaces fully in C# for WinUI 3 (Windows App SDK) and Uno Platform (including WebAssembly), leveraging a Flutter-like development experience with .NET Hot Reload. This approach eliminates the need for XAML, HTML, JavaScript, or CSS.
  3. Use C# Markup with LiveChartsCore.SkiaSharpView.Uno

    master
    This package provides the C# Markup 2 API for the LiveChartsCore.SkiaSharpView.Uno NuGet package. It allows you to build charts and data visualizations fully in C# without using XAML, HTML, JavaScript, or CSS. This is specifically designed for developers using WinUI 3 (Windows App SDK) or the Uno Platform (including WebAssembly).
  4. Use C# Markup 2 with Uno.Toolkit.WinUI

    master

    C# Markup 2 provides a Flutter-like UI development experience for Uno.Toolkit.WinUI. It allows you to build .NET applications fully in C# without requiring XAML, HTML, JavaScript, or CSS. This toolkit is designed to target WinUI 3 (Windows App SDK) and the Uno Platform, including WebAssembly (WASM) for browsers.

    Key benefits include:

    • Full C# UI Development: Define your entire UI using C# code.
    • Cross-Platform: Target browsers, native desktop, and mobile.
    • Hot Reload Support: Leverage .NET Hot Reload for a fast development cycle.
  5. Use C# Markup with Uno.Extensions.Navigation.WinUI

    master
    This package provides a C# Markup 2 API specifically for the Uno.Extensions.Navigation.WinUI NuGet package. It allows you to define your UI and navigation logic fully in C#, targeting WinUI 3 (Windows App SDK) and the Uno Platform (including WebAssembly), without requiring XAML, HTML, JavaScript, or CSS. It is designed to work with C# 14 and .NET 9 to provide a Flutter-like development experience with .NET Hot Reload.
  6. Key features and benefits of C# Markup 2

    master

    C# Markup 2 provides a Flutter-like development experience for .NET UI frameworks (WinUI, WPF, Uno Platform). Key advantages include:

    • Reduced Verbosity: Eliminates repetitive syntax like new , HorizontalAlignment = HorizontalAlignment.Center, () => , nameof(), and explicit property bindings (e.g., automatically binding to Text for TextBlock).
    • Namespace Separation: Uses separate markup namespaces to prevent IntelliSense pollution. You can see only Markup APIs while editing UI files (e.g., MyPage.cs) and UI framework APIs while editing logic files (e.g., MyPage.logic.cs).
    • Performance: Designed to be practically allocation-free and reflection-free for handling large UIs efficiently.
    • Full C# Workflow: No XAML, HTML, JavaScript, or CSS required. Supports built-in MVVM or other models like Uno's MVUX or ReactiveUI.
    • Cross-Platform: Targets browsers, native desktop, and mobile via supported frameworks.
  7. C# Markup 4.0 Compatibility and Supported Technologies

    master

    C# Markup 4.0 is the latest major release, updated for modern .NET environments. It supports:

    • Languages & Runtimes: C# 14, .NET 10, and .NET 9.
    • Uno Platform: All Uno Platform libraries are updated to the latest .NET version supported by Uno SDK 6.5 (including .NET 10 and .NET 9).
    • Third-party Library Support:
      • LiveCharts2: Updated to 2.0 stable and .NET 10.
      • Mapsui 5: Updated to 5.0 stable and .NET 9.
      • ScottPlot.NET: Updated to 5.1 and .NET 10.
  8. Use C# Markup 2 with Uno.Extensions.Navigation.Toolkit.WinUI

    master
    This package provides the C# Markup 2 API specifically for the Uno.Extensions.Navigation.Toolkit.WinUI NuGet package. It allows you to build user interfaces fully in C# for WinUI 3 (Windows App SDK) and Uno Platform (including WebAssembly) without requiring XAML, HTML, JavaScript, or CSS. It is designed to provide a Flutter-like UI development experience leveraging .NET Hot Reload.
  9. Use C# Markup 2 with ScottPlot.WinUI

    master

    This package provides a Flutter-like UI development experience for ScottPlot.WinUI. It allows you to build user interfaces for ScottPlot charts fully in C#, eliminating the need for XAML, HTML, JavaScript, or CSS. This specific implementation targets WinUI 3 (Windows App SDK) and Uno Platform (including browser WebAssembly).

    /* This package provides a C# Markup 2 API for the ScottPlot.WinUI NuGet package. */
  10. Integrate UI markup with UI logic using Assign and Invoke

    master

    To bridge the gap between the markup declaration and the logic file, use Assign and Invoke. These methods safely pass the actual UI framework object (the real control) from the markup object to your logic code.

    • Assign: Used to capture a reference to a UI control created in markup and assign it to a field or property in your logic class.
    • Invoke: Used to trigger logic or methods within your logic class directly from the markup expression.

    Crucial Distinction: In your markup file, StackPanel refers to the CSharpMarkup type. In your logic file, StackPanel refers to the actual UI framework type.