Primary WinUI APIs:
Primary Avalonia APIs:
| WinUI idiom | Avalonia idiom |
|---|---|
| ExtendsContentIntoTitleBar + SetTitleBar | ExtendClientAreaToDecorationsHint + custom title region |
| AppWindow.TitleBar color tuning | style/theme resources for title surface |
| SystemBackdrop (Mica/Acrylic) | TransparencyLevelHint (Mica, AcrylicBlur, Blur) |
| non-client drag handling | BeginMoveDrag / BeginResizeDrag |
WinUI XAML:
<Grid>
<Grid x:Name="AppTitleBar" Height="36">
<TextBlock Text="MyApp" VerticalAlignment="Center" Margin="12,0" />
</Grid>
<ContentPresenter Margin="0,36,0,0" />
</Grid>
WinUI C#:
ExtendsContentIntoTitleBar = true;
SetTitleBar(AppTitleBar);
SystemBackdrop = new MicaBackdrop();
AppWindow.Title = "MyApp";
Avalonia XAML:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ExtendClientAreaToDecorationsHint="True"
ExtendClientAreaChromeHints="PreferSystemChrome"
ExtendClientAreaTitleBarHeightHint="36"
SystemDecorations="Full">
<Grid RowDefinitions="36,*">
<Border Grid.Row="0" Background="{DynamicResource ThemeControlMidBrush}" PointerPressed="OnTitleBarPressed">
<TextBlock Text="MyApp" VerticalAlignment="Center" Margin="12,0" />
</Border>
<ContentPresenter Grid.Row="1" />
</Grid>
</Window>
Avalonia C#:
TransparencyLevelHint = new WindowTransparencyLevelCollection(new[]
{
WindowTransparencyLevel.Mica,
WindowTransparencyLevel.AcrylicBlur,
WindowTransparencyLevel.Blur,
WindowTransparencyLevel.None
});
private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
BeginMoveDrag(e);
}