Layout & Navigation
Use NavigationView and SplitView to create responsive navigation that adapts to different screen sizes.
<NavigationView>
<NavigationView.MenuItems>
<NavigationViewItem Content="Home" Icon="Home"/>
<NavigationViewItem Content="Settings" Icon="Setting"/>
</NavigationView.MenuItems>
</NavigationView>
Show Live Demo
Performance
Prefer lazy loading and UI virtualization for large data sets. Use ItemsRepeater with DataVirtualizingCollection.
var items = new DataVirtualizingCollection(
async (start, count) => await LoadChunkAsync(start, count),
totalCount);
myRepeater.ItemsSource = items;
Show Tip
Enable EnableCache on Image controls to reduce network requests.
Accessibility
All WinUI controls are built with accessibility in mind. Add AutomationProperties.Name where needed.
<Button Content="Submit" AutomationProperties.Name="Submit form"></Button>
Show Demo
Theming & Styling
Leverage ThemeResources to switch between Light, Dark, and High Contrast modes.
<ResourceDictionary>
<SolidColorBrush x:Key="ControlBackground" Color="{ThemeResource SystemControlPageBackgroundBaseLowBrush}" />
</ResourceDictionary>
Show Theme Switcher
Common UI Patterns
- Master‑Detail: Use
NavigationViewwith a detail pane. - Flyout: Leverage
MenuFlyoutfor context menus. - Dialog: Use
ContentDialogfor modal interactions.
Testing & Debugging
Integrate WinAppDriver for UI automation and use XAML Diagnostics to inspect visual trees at runtime.
WinAppDriver.exe
dotnet test MyApp.UITests.csproj