FmgLib.MauiMarkup Documentation

August 15, 2026 · View on GitHub

FmgLib.MauiMarkup is a fluent C# markup library for .NET MAUI. It lets you build your entire user interface in pure C# — no XAML required — using readable, chainable extension methods that are automatically generated for every bindable property and event of every MAUI control.

new Label()
    .Text("Hello, FmgLib!")
    .FontSize(30)
    .TextColor(Colors.Green)
    .Center()

This documentation is a complete, self-contained guide to the library. Every topic from the project README is covered here in much greater depth, together with usage patterns discovered directly from the library source code.

Table of Contents

1. Fundamentals

DocumentWhat you will learn
Getting StartedInstallation, project templates, first app, project structure
From XAML to C#How XAML concepts map to FmgLib.MauiMarkup, side-by-side conversions
Fluent PropertiesThe four overload patterns, theme/platform/idiom-aware values, dynamic resources
Object References (Assign)Assign, InvokeOnElement, RegisterName, referencing controls without fields

2. Data Binding

DocumentWhat you will learn
Property BindingsPath, Source, BindingMode, StringFormat, fallback values, the low-level Bind() API
Binding ConvertersInline Convert/ConvertBack, IValueConverter, func-based converters
MultiBindingCombining several bindings into one property, IMultiValueConverter
Compiled BindingsGetter/Setter expression bindings, Binding.Create, performance

3. Layout

DocumentWhat you will learn
Layout OptionsAlignment and fill helpers (Center, AlignTopLeft, FillHorizontal, …)
GridRow/column definition builders (Star, Auto, Absolute), positioning children
Text AlignmentITextAlignment helpers (TextCenter, TextTopLeft, …)
Attached PropertiesFull mapping table and examples for Grid, Shell, Semantic, Automation, …

4. Interaction

DocumentWhat you will learn
Event HandlersOn<EventName> methods, method groups vs. inline lambdas
Gesture RecognizersTap, pan, pointer, swipe, pinch, drag & drop
BehaviorsAttaching reusable behaviors, writing custom behaviors
TriggersProperty, data, event, multi and state triggers
MenusContext menus (MenuFlyout), menu bars, keyboard accelerators
SwipeViewSwipe-to-action rows, SwipeItems, custom swipe content

5. Appearance

DocumentWhat you will learn
StylingStyle<T>, resource dictionaries, BasedOn, derived types, app-wide themes
Visual StatesVisualState<T>, built-in state names, state-driven animations
Gradients & BrushesLinear/radial gradients, solid brushes, shadows
Shapes & GeometriesLines, rectangles, ellipses, polygons, Path geometries, clipping
Formatted TextFormattedString/Span, mixed styling, tappable inline links
AnimationsGenerated Animate…To helpers, MAUI animation interop

6. Application Architecture

DocumentWhat you will learn
Shell ApplicationsBuilding a Shell in C#, flyouts, tabs, templates, navigation
Application & WindowsApplication setup, window lifecycle, TitleBar, NavigationPage/TabbedPage/FlyoutPage
Hot ReloadIFmgLibHotReload, FmgLibContentPage, MVVM page bases
Collections & TemplatesCollectionView, ItemTemplate overloads, BindableLayout, EmptyView
Localization (JSON)JSON-file based localization, runtime language switching
Localization (RESX)RESX-based localization with TranslatorResx

7. Extensibility & Reference

DocumentWhat you will learn
Third-Party Controls[MauiMarkup], [MauiMarkupAttachedProp], automatic generator mode
Custom Extension MethodsWriting your own fluent methods that work everywhere
UtilitiesToColor, collection helpers, AddRangeMarkup, style interop
Complete ExamplesFull pages: login screen, product list, settings page, MVVM patterns
Tips & TroubleshootingCommon pitfalls, naming rules, FAQ
AI SkillsTen installable skill bundles that teach AI coding agents to write correct FmgLib.MauiMarkup
vs. CommunityToolkit.Maui.MarkupHonest feature-by-feature comparison of the two C# markup libraries for MAUI

🇹🇷 Bu dokümantasyonun Türkçe sürümü tr/ klasöründedir.

Suggested Learning Path

  1. New to the library? Read Getting Started, then From XAML to C# and Fluent Properties. These three explain 80% of everyday usage.
  2. Building real pages? Continue with Layout Options, Grid, Property Bindings and Hot Reload.
  3. Polishing an app? Styling, Visual States, Triggers and Animations.
  4. Shipping to multiple markets? Localization (JSON) or Localization (RESX).
  5. Using SkiaSharp, ZXing, UraniumUI, InputKit…? Third-Party Controls.

Package Overview

PackagePurpose
FmgLib.MauiMarkupThe markup library itself + the Roslyn source generator
FmgLib.MauiMarkup.Templatedotnet new project template (fmglib-mauimarkup-app)

Core Idea in 30 Seconds

Every bindable property of every MAUI control gets a fluent extension method with the same name as the property. Every event gets an On<EventName> method. All methods return the control itself, so calls chain naturally and the nesting of your C# code mirrors the visual tree — just like XAML, but with full IntelliSense, refactoring, compile-time safety, and no context switching between two languages.

public partial class MainPage : ContentPage, IFmgLibHotReload
{
    int count = 0;

    public MainPage() => this.InitializeHotReload();

    public void Build() =>
        this.Content(
            new VerticalStackLayout()
            .Spacing(25)
            .Padding(30)
            .Center()
            .Children(
                new Image()
                    .Source("dotnet_bot.png")
                    .HeightRequest(200)
                    .CenterHorizontal(),

                new Label()
                    .Text("Hello, World!")
                    .FontSize(32)
                    .CenterHorizontal(),

                new Button()
                    .Text("Click me")
                    .OnClicked(b => b.Text = $"Clicked {++count} times")
                    .CenterHorizontal()
            )
        );
}