C# Markup Documentation
repository·master·Indexed 21 days ago
https://github.com/vincenth-net/csharpformarkupA 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.
What's inside C# Markup
- C# Markup allows you to build .NET applications fully in C#, eliminating the need for XAML. It provides a Flutter-like UI development experience that leverages .NET Hot Reload. This specific preview version targets WPF using C# 10 and .NET 6.
Overview of C# Markup 2
masterC# 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.
Use C# Markup with Uno.Extensions.Reactive.WinUI
masterThis package provides the C# Markup 2 API specifically for theUno.Extensions.Reactive.WinUINuGet 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.Use C# Markup with LiveChartsCore.SkiaSharpView.Uno
masterThis package provides the C# Markup 2 API for theLiveChartsCore.SkiaSharpView.UnoNuGet 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).Use C# Markup 2 with Mapsui.Uno.WinUI
masterThis package provides the C# Markup 2 API for the Mapsui.Uno.WinUI NuGet package. It allows you to build map-based user interfaces fully in C# without using XAML, HTML, JavaScript, or CSS. This approach enables a Flutter-like development experience with .NET Hot Reload, targeting WinUI 3 (Windows App SDK) and Uno Platform (including WebAssembly).Use C# Markup 2 with Uno.Toolkit.WinUI
masterC# 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.
Use C# Markup with Uno.Extensions.Navigation.WinUI
masterThis package provides a C# Markup 2 API specifically for theUno.Extensions.Navigation.WinUINuGet 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.Key features and benefits of C# Markup 2
masterC# 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 toTextforTextBlock). - 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.
- Reduced Verbosity: Eliminates repetitive syntax like
C# Markup 4.0 Compatibility and Supported Technologies
masterC# 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.
Use C# Markup 2 with Uno.Extensions.Navigation.Toolkit.WinUI
masterThis package provides the C# Markup 2 API specifically for theUno.Extensions.Navigation.Toolkit.WinUINuGet 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.Use C# Markup 2 with ScottPlot.WinUI
masterThis 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. */Integrate UI markup with UI logic using Assign and Invoke
masterTo bridge the gap between the markup declaration and the logic file, use
AssignandInvoke. 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,
StackPanelrefers to theCSharpMarkuptype. In your logic file,StackPanelrefers to the actual UI framework type.