Skip to content

feat: TitleBar UI - #21917

Merged
MartinZikmund merged 22 commits into
feature/breakingchangesfrom
dev/mazi/titlebar
Jul 31, 2026
Merged

MartinZikmund merged 22 commits into
feature/breakingchangesfrom
dev/mazi/titlebar

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Nov 21, 2025 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #21714

PR Type:

What is the current behavior? 🤔

What is the new behavior? 🚀

PR Checklist ✅

Please check if your PR fulfills the following requirements:

Other information ℹ️

Copilot AI review requested due to automatic review settings November 21, 2025 14:16
@MartinZikmund MartinZikmund self-assigned this Nov 21, 2025
@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Nov 21, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces the TitleBar UI control implementation for the Uno Platform, providing a customizable title bar component for windowing scenarios. The implementation includes core control classes, dependency properties, automation support, and sample pages for testing and demonstration.

Key Changes

  • New TitleBar control with support for icons, titles, subtitles, headers, and custom content areas
  • Automation peer implementation for accessibility
  • Template settings for data binding
  • Integration with window management APIs for proper padding and non-client region handling
  • Sample pages demonstrating TitleBar usage in both standalone and window contexts

Reviewed changes

Copilot reviewed 12 out of 15 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
TitleBar.cs Main partial class declaration with ContentProperty attribute
TitleBar.Properties.cs Dependency property definitions for all TitleBar properties and events
TitleBar.mux.cs Core implementation with lifecycle methods, event handlers, and UI update logic
TitleBar.mux.h.cs Private fields, constants for template parts and visual states
TitleBarTemplateSettings.cs Template settings class for IconElement binding
TitleBarAutomationPeer.cs Automation peer for accessibility support
Generated/.../TitleBar.cs Generated stub file with conditional compilation updated to enable implementation
Generated/.../TitleBarTemplateSettings.cs Generated template settings stub updated
Generated/.../TitleBarAutomationPeer.cs Generated automation peer stub updated
ResourceAccessor.ResourceKeys.cs Added resource key for pane toggle button name
TitleBarPage.xaml/.cs Sample page demonstrating basic TitleBar usage
TitleBarPageWindow.xaml/.cs Window sample with comprehensive TitleBar configuration options
UITests.Shared.projitems Project file updated to include new test pages

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Jan 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions Bot closed this Jan 31, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 2, 2026
@MartinZikmund MartinZikmund reopened this May 18, 2026
@unoplatform unoplatform unlocked this conversation May 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

XAML Styler drift detected on 52b81a6

XAML files under src/SamplesApp/ are not formatted according to src/SamplesApp/Settings.XamlStyler.

To apply automatically (PRs from branches in this repo only): comment /apply-xaml-style on this PR and a bot will push chore: Apply XAML styler to the head branch.

To apply manually (required for PRs from forks):

  1. Download the xaml-style-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply xaml-style.patch
    git add -A
    git commit -m "chore: Apply XAML styler"
    git push
    

Or re-run the formatter locally: dotnet tool restore && dotnet xstyler -d src/SamplesApp -r.

@MartinZikmund MartinZikmund removed the stale This item has been marked as stale and will be closed if there is no activity. label May 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 52b81a6

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

Copilot AI review requested due to automatic review settings May 18, 2026 12:01
@github-actions

Copy link
Copy Markdown
Contributor

XAML Styler drift detected on 7dffaf2

XAML files under src/SamplesApp/ are not formatted according to src/SamplesApp/Settings.XamlStyler.

To apply automatically (PRs from branches in this repo only): comment /apply-xaml-style on this PR and a bot will push chore: Apply XAML styler to the head branch.

To apply manually (required for PRs from forks):

  1. Download the xaml-style-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply xaml-style.patch
    git add -A
    git commit -m "chore: Apply XAML styler"
    git push
    

Or re-run the formatter locally: dotnet tool restore && dotnet xstyler -d src/SamplesApp -r.

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 7dffaf2

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 15 comments.

Comments suppressed due to low confidence (2)

src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TitleBarTests/TitleBarPageWindow.xaml.cs:7

  • System.Diagnostics is imported but not used in this file. With TreatWarningsAsErrors, this unused using will fail the build; remove it or use the referenced types.
using System.Diagnostics;

src/Uno.UI/UI/Xaml/Controls/TitleBar/TitleBar.mux.cs:589

  • The coordinate validity check uses X >= 0 || Y >= 0, which will accept rects with a negative X or negative Y. Require both coordinates to be non-negative (or skip if either is negative) before adding the icon rect.
					var iconRect = GetBounds(iconViewbox);

					if (iconRect.X >= 0 || iconRect.Y >= 0)
					{
						iconRects.Add(iconRect);

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

XAML Styler drift detected on c562aff

XAML files under src/SamplesApp/ are not formatted according to src/SamplesApp/Settings.XamlStyler.

To apply automatically (PRs from branches in this repo only): comment /apply-xaml-style on this PR and a bot will push chore: Apply XAML styler to the head branch.

To apply manually (required for PRs from forks):

  1. Download the xaml-style-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply xaml-style.patch
    git add -A
    git commit -m "chore: Apply XAML styler"
    git push
    

Or re-run the formatter locally: dotnet tool restore && dotnet xstyler -d src/SamplesApp -r.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on c562aff

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

Copilot AI review requested due to automatic review settings June 3, 2026 11:44
MartinZikmund and others added 13 commits July 30, 2026 10:39
Sync the TitleBar control with the latest WinUI C++ sources, porting the
drift between commit 5f9e85113 and fc2f82117:

- Add AutoRefreshDragRegions DP and the IsDragRegion attached property
  (GetIsDragRegion/SetIsDragRegion) plus RecomputeDragRegions().
- Port FindInteractableElements recursive drag-region detection, replacing
  the flat content-area registration in UpdateInteractableElementsList.
- Port app-window title sync (UpdateTitle/ResetTitle/HandleTitleChange) and
  the cached TryGetAppWindow helper.
- Port OnContentLayoutUpdated one-shot/auto-refresh layout tracking and the
  passthrough-rects caching in UpdateDragRegion.
- Fix the OnPropertyChanged else-if chain and add the AutoRefreshDragRegions
  branch.

Also make the in-progress port build:
- Reconcile the TitleBar and TitleBarTemplateSettings generated stubs to the
  implemented form (#if false guards) so they no longer collide with the
  hand-written implementation.
- Register the FlowDirection changed callback via RegisterPropertyChangedCallback
  so the (DependencyObject, DependencyProperty) handler signature matches.

Validated: Uno.UI.Skia builds clean; adversarial multi-agent review found no
fidelity divergences from the C++ source.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Capture activation listener in a local in OnApplyTemplate so the
  revoker unsubscribes from the correct instance on template re-apply
- Return string.Empty fallback from TitleBarAutomationPeer.GetNameCore
  to preserve WinUI's non-null name contract
- Remove unused usings and document Win32 constants in TitleBar samples

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Regenerate themeresources_v2.xaml to include the TitleBar style and
  theme brushes (the BatchMergeXaml output was missing them), fixing the
  Given_Control.When_Non_BuiltIn_Control default-style lookup
- Remove unused s_layoutRootPartName const (IDE0051); WinUI declares it
  but never retrieves PART_LayoutRoot, so it is dead here too

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
WinUI revokes the InputActivationListener subscription in the C++
~TitleBar destructor. Uno has no deterministic finalizer, so the
subscription is now attached on Loaded and detached on Unloaded
(reattaching on re-add), preventing the listener from rooting the
TitleBar once the API is implemented. ResetTitle-on-GC is left out
deliberately to avoid window-title flicker on tree detach.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0146Uxqo6gG5TzZv5bBvRZK9
Mark the IsDragRegionProperty getter with [DynamicDependency] for
GetIsDragRegion/SetIsDragRegion so WASM/NativeAOT trimming preserves
the attached-property accessors used by XAML.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0146Uxqo6gG5TzZv5bBvRZK9
UITests.Shared compiles into every head and the Skia head runs on
macOS/Linux; guard the user32.dll caption-button swap with a runtime
OperatingSystem.IsWindows() check to avoid DllNotFoundException.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0146Uxqo6gG5TzZv5bBvRZK9
@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 51s —— View job


Code Review Complete

  • Gather context and understand the request
  • Review diff against base branch
  • Review TitleBar core implementation (TitleBar.mux.cs, TitleBar.mux.h.cs)
  • Review TitleBar.Properties.cs and attached property handling
  • Review automation peer and sample pages
  • Post inline comments for findings
  • Post summary

Summary

All medium-severity findings from prior review rounds are resolved in the latest commits. The implementation is clean for merge.

Fixed in recent commits (confirmed):

Finding Fixed in
false used as bool DP defaults → default(bool) b12f7845 — IsBackButtonVisible (197), IsPaneToggleButtonVisible (217), AutoRefreshDragRegions (237)
Missing [DynamicDependency] on IsDragRegion accessors ed199428 — correctly placed on IsDragRegionProperty getter per InfoBarPanel/RelativePanel pattern
Windows-only user32.dll P/Invoke in shared file d5dde144 — OperatingSystem.IsWindows() runtime guard in UpdateCaptionButtonDirection
Reversed comment in TitleBarPageWindow.xaml.cs eeaba4e5
Lifecycle leak — InputActivationListener not revoked on Unloaded a8ea9b30 — scoped to live tree via OnLoaded/OnUnloaded; AttachInputActivationListener correctly captures local before revoker

0 new inline findings this round. The code is clean.

Intentional won't-fix (confirmed 1:1 WinUI port):

  • XamlRoot.RasterizationScale without null guard (TitleBar.mux.cs:682) — call chain guarantees non-null; diverging from WinUI is undesirable
  • null event args for BackRequested/PaneToggleRequested — matches WinUI's nullptr
  • X >= 0 || Y >= 0 rect filtering in UpdateDragRegion/UpdateIconRegion — verbatim from TitleBar.cpp
  • Unused xmlns:exp in TitleBarPage.xaml — present in upstream WinUI test page

Cross-cutting carry-over: No automated runtime tests cover the new TitleBar control. Manual samples (TitleBarPage, TitleBarPageWindow) demonstrate the surface, but Uno.UI.RuntimeTests tests would give regression coverage for visual-state transitions, drag region updates, and property bindings. Worth a follow-up issue if not addressed before merge.

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on b12f784

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund

Copy link
Copy Markdown
Member Author

/apply-sync-gen

@github-actions

Copy link
Copy Markdown
Contributor

The apply workflow failed. See the workflow logs for details.

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 41s —— View job


Code Review Complete

  • Gather context and understand the request
  • Review TitleBar core implementation (TitleBar.mux.cs, TitleBar.mux.h.cs)
  • Review TitleBar.Properties.cs and attached property handling
  • Review automation peer and template settings
  • Review sample pages
  • Post inline comments for findings
  • Post summary

Summary

The two new commits since the last review round are correct and clean.

b12f7845 (style): Replaces false with default(bool) for IsBackButtonVisible, IsPaneToggleButtonVisible, and AutoRefreshDragRegions — false and default(bool) are identical for bool, purely a style conformance to the repo rule. No functional impact.

75791ebd (chore): Reduces #if false || false || false || false || false || false to #if false || false in Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/TitleBar.cs. Both expressions always evaluate to false, so the [Uno.NotImplemented] attribute is never applied in either case. This manually resolves the sync generator drift that the /apply-sync-gen workflow failed to auto-apply. Note: AGENTS.md asks not to edit files under Generated/ folders; the manual edit was forced by the apply-workflow failure and the change is trivially correct, but CI's sync generator check should be watched to confirm no residual drift.

0 new inline findings this round. All medium-severity issues from prior rounds remain fixed.

Confirmed won't-fix (intentional 1:1 WinUI port):

  • null event args for BackRequested/PaneToggleRequested — matches WinUI's nullptr
  • XamlRoot.RasterizationScale without null guard (TitleBar.mux.cs:682) — call chain guarantees non-null
  • X >= 0 || Y >= 0 rect filtering in drag/icon region updates — verbatim from TitleBar.cpp
  • xmlns:exp unused in TitleBarPage.xaml:7 — present in upstream WinUI test page

Cross-cutting carry-over: No automated runtime tests cover the new TitleBar control. Manual samples (TitleBarPage, TitleBarPageWindow) demonstrate the surface; Uno.UI.RuntimeTests tests would give regression coverage for visual-state transitions, drag region updates, and property bindings.

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 21s —— View job


Code Review Complete

  • Gather context and understand the request
  • Review new commits since last review (preprocessor directive removals, sync generator)
  • Review TitleBar core files for any remaining issues
  • Post inline comments for findings
  • Post summary

Summary

The two commits pushed since the July 30 review (75791ebd, 556f99ea) make only cosmetic cleanups to two auto-generated files:

File Change
Generated/.../TitleBar.cs #if false || false || false || false || false || false → #if false || false
Generated/.../TitleBarTemplateSettings.cs same simplification

Both evaluate identically (false), so [Uno.NotImplemented] is still never applied. These are the output of the WinAppSDK sync generator applied manually after the /apply-sync-gen bot workflow failed.

0 new findings this round. The implementation remains clean.

All findings from prior rounds confirmed resolved:

Finding Status
Lifecycle leak — InputActivationListener not revoked on Unloaded ✅ Fixed — OnLoaded/OnUnloaded scoped subscription
Missing [DynamicDependency] on IsDragRegion accessors ✅ Fixed — on IsDragRegionProperty getter per InfoBarPanel/RelativePanel pattern
Windows-only user32.dll P/Invoke without guard ✅ Fixed — OperatingSystem.IsWindows() runtime guard
Reversed comment in TitleBarPageWindow.xaml.cs ✅ Fixed
false as bool DP defaults instead of default(bool) ✅ Fixed — IsBackButtonVisible, IsPaneToggleButtonVisible, AutoRefreshDragRegions
Mutable field capture in revoker lambda ✅ Fixed — captured via local variable
GetNameCore returning null ✅ Fixed — returns name ?? string.Empty

Intentional won't-fix (confirmed 1:1 WinUI port):

  • XamlRoot.RasterizationScale without null guard — call chain guarantees non-null; 1:1 WinUI parity
  • null event args for BackRequested/PaneToggleRequested — matches WinUI's nullptr
  • X >= 0 || Y >= 0 rect filtering — verbatim from TitleBar.cpp
  • Unused xmlns:exp in TitleBarPage.xaml — present in upstream WinUI test page

Cross-cutting carry-over: No automated runtime tests cover the new TitleBar control. Manual samples (TitleBarPage, TitleBarPageWindow) demonstrate the surface, but Uno.UI.RuntimeTests tests would give regression coverage for visual-state transitions, drag region updates, and property bindings. Worth a follow-up issue if not addressed before merge.

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 75791eb

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 224945 found UI Test snapshots differences: skia-linux-screenshots: 88, skia-windows-screenshots: 93

Details
  • skia-linux-screenshots: 88 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • Gamepad_Enumeration.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageSourceUrlMsAppDataScheme.png
    • Image_Margin_Large.png-dark
    • Image_UseTargetSizeLate.png-dark
    • Image_UseTargetSizeLate.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • EllipsemaskingEllipseGrid.png
    • Image_AnimatedWebP.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • Examples.png
  • skia-windows-screenshots: 93 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Buttons.png-dark
    • Buttons.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_CurrentReading.png-dark
    • ImageBrushAlignmentXY.png-dark
    • ImageBrushAlignmentXY.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ContextRequested.png-dark
    • Image_AnimatedWebP.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • Examples.png

@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@MartinZikmund
MartinZikmund merged commit cd56a7d into feature/breakingchanges Jul 31, 2026
49 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/titlebar branch July 31, 2026 07:46
@github-actions github-actions Bot mentioned this pull request Jul 31, 2026
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure area/code-generation Categorizes an issue or PR as relevant to code generation area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform platform/x11 🐧 Categorizes an issue or PR as relevant to X11

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WinUI TitleBar

6 participants