Build with XuiView Markdown

Reference

Build a Xui app in C#, from your first page to responsive desktop and mobile interfaces, custom controls, Canvas drawing, and GPU rendering.

Follow these guides to build an app by hand, then explore the features your product needs. Articles include compiled examples, runnable demos where the renderer supports them, and explicit platform limits. Each page also has a Markdown version with the same explanations and expanded source code for coding assistants.

Start with Getting Started, then follow App foundations to build a small app. Then follow the topics your app needs. The API reference provides the current public declarations alongside these guides.

Contents

  1. App foundations
  2. Navigation, views, and input
  3. Graphics and 3D
  4. Testing and release

App foundations

Your first app

  • Getting Started - Install .NET and the Xui template, create an app, and run it in the emulator.
  • Understand the generated project - Shared app sources, platform entry points, project files, assets, and the role of each package.
  • Application, window, and view - How an application creates a window, how a root view hosts content, and where platform runtimes fit.
  • Build your first page - Compose a logo, text, and buttons; respond to a click; update what the user sees.
  • Run and iterate - Choose a host, use the phone emulator, resize and rotate, and understand when to rebuild or restart.

Layout and adaptive interfaces

  • How layout works - Measure and arrange, constraints, desired size, alignment, margin, and padding.
  • Stacks and FlexBox - Build rows and columns, distribute space, align children, and wrap content.
  • Grid layouts - Use fixed, automatic, and fractional tracks, spans, and named areas.
  • Adapt to available space - Choose width thresholds, reflow content, and share a page between a phone and a resizable desktop window.
  • Safe areas and device geometry - Account for display scale, orientation, insets, and the on-screen keyboard.
  • Scrolling content - Size a scroll view, nest it in layouts, and handle content larger than the viewport.

Controls and visual design

  • Core views and ToolKit widgets - Choose between basic views and styled buttons, cards, toggles, checkboxes, and other shared widgets.
  • Themes and design tokens - Apply consistent colors, typography, spacing, and corner shapes; respond to preference changes.
  • Text, fonts, and images - Load assets, choose fonts, measure text, and size images without distortion.
  • Lists and repeated content - Present collections, handle selection, and understand the current list implementation's limits for large data sets.
  • Accessible interaction - Design readable text, visible focus, useful target sizes, and keyboard alternatives; document current native accessibility support and gaps.

State and application services

Pages and navigation

  • Create a page - Structure a page with content, actions, and local state using ToolKit navigation primitives.
  • Connect pages with NavigationShell - Define navigation items, select a destination, and choose the initial page.
  • Mobile navigation and back - Move from a home page into child pages, return to the previous page, and account for platform back behavior.
  • Desktop navigation - Use a left menu to change the main content, with compact and expanded navigation at narrow widths.
  • Page state and lifetime - Pass data to a destination, decide when to preserve or recreate content, and stop page work when navigating away.
  • Overlays and additional windows - Choose an in-window popup or a separate desktop window; open, dismiss, and clean it up with its owner.

Custom views

Events and pointer input

  • Follow an event through Xui - Trace runtime events through the window, root view, hit testing, and view event routing; understand propagation and handling.
  • Mouse interaction on desktop - Handle movement, buttons, hover, and leaving a view without assuming touch has a hover state.
  • Touch interaction on mobile - Track contact identities, phases, multiple contacts, and cancellation.
  • Shared pointer gestures - Build tap and drag behavior with the pointer gesture contracts, capture, and competing gesture candidates.
  • Scrolling and trackpads - Handle wheel deltas and touch scrolling, nested scroll regions, and platform-specific momentum information.
  • Zoom and coordinate conversion - Handle magnification separately from scrolling, map input into local coordinates, and interact with transformed content.

Keyboard and text input

  • Focus and keyboard navigation - Move focus, use Tab and Shift+Tab, show focus feedback, and restore focus after an overlay closes.
  • Keys and shortcuts - Handle key presses and modifiers, distinguish commands from text entry, and account for platform conventions.
  • TextBox and TextInput - Add editable fields, choose input options, bind app state, and show validation feedback.
  • Editing and selection - Understand caret movement, selection, deletion, clipboard operations, and Unicode text boundaries.
  • IME and soft keyboards - Distinguish committed text from composition, request an appropriate mobile keyboard, and keep the focused field visible; identify runtime support gaps.
  • Custom text editors - Implement the text-editing client contract and connect editing state, selection, rendering, and platform input.

Graphics and 3D

Canvas and 2D drawing

Animation

GPU and 3D drawing

This part of Xui is experimental. These articles state the supported backends and limitations of each example, including what happens when GPU rendering is unavailable.

Testing and release

Testing

  • Test app logic and controls - Choose unit, component, integration, or end-to-end tests for the behavior being checked.
  • Deterministic UI tests - Use the test runtime to control time and input, navigate pages, and make assertions without a native window.
  • Visual regression tests - Capture SVG or raster output, use consistent fonts and device geometry, and review snapshot changes.

Debugging and performance

  • Inspect a running app - Use DevTools and the MCP tooling to inspect views, capture screenshots, and reproduce input sequences.
  • Debug layout and input - Diagnose constraints, clipping, hit testing, focus, gesture conflicts, and desktop/mobile differences.
  • Measure performance and allocations - Find unnecessary layouts and frames, inspect resource use, and keep hot input and drawing paths allocation-conscious.

Running and shipping

  • Desktop apps - Build and run on Windows and macOS, configure native windows, and understand distribution prerequisites.
  • Mobile apps - Set up Android and iOS tooling, run on simulators and devices, and distinguish emulator behavior from native behavior.
  • Browser apps - Build WebAssembly assets, host them statically, and account for loading, browser restrictions, and deployment paths.
  • Platform support and fallbacks - Check the actual runtime implementation, design around unavailable features, and keep platform-specific code at the edge of the app.
  • Troubleshooting setup and builds - Diagnose SDK, workload, package, native toolchain, and asset-loading problems with reproducible commands.