-
-
Notifications
You must be signed in to change notification settings - Fork 900
feat(controls): Add TitleBar CenterContent property
#1484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
minimizing changes
TitleBar CenterContent property
Merge 2025-11-12 from base repo
There was a problem hiding this comment.
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 adds a CenterContent property to the TitleBar control, enabling developers to place content in the center area of the title bar.
Key changes:
- New
CenterContentdependency property with getter/setter - Updated XAML template with additional grid column for centered content
- Enhanced mouse hit-testing logic to handle center content interactions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | Added CenterContent dependency property and updated window procedure hook to handle mouse-over detection for center content |
| src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml | Added new grid column and ContentPresenter for center content, reordered existing columns |
| if (message == PInvoke.WM_NCHITTEST) | ||
| { | ||
| if (TrailingContent is UIElement || Header is UIElement || CenterContent is UIElement) | ||
| { | ||
| UIElement? headerLeftUIElement = Header as UIElement; | ||
| UIElement? headerCenterUIElement = CenterContent as UIElement; | ||
| UIElement? headerRightUiElement = TrailingContent as UIElement; | ||
|
|
||
| var e = new HwndProcEventArgs(hwnd, msg, wParam, lParam, isMouseOverHeaderContent); | ||
| WndProcInvoked?.Invoke(this, e); | ||
| isMouseOverHeaderContent = (headerLeftUIElement is not null && headerLeftUIElement != _titleBlock && headerLeftUIElement.IsMouseOverElement(lParam)) | ||
| || (headerCenterUIElement?.IsMouseOverElement(lParam) ?? false) | ||
| || (headerRightUiElement?.IsMouseOverElement(lParam) ?? false); | ||
| } | ||
|
|
||
| if (e.ReturnValue != null) | ||
| { | ||
| handled = e.Handled; | ||
| return e.ReturnValue ?? IntPtr.Zero; | ||
| } | ||
| htResult = GetWindowBorderHitTestResult(hwnd, lParam); | ||
| } |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs are used for indentation instead of spaces. According to the project's .editorconfig, C# files should use spaces (indent_style = space). Please replace tabs with spaces for consistent formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| } | ||
|
|
||
| switch (message) | ||
| switch (message) |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tab used for indentation instead of spaces. According to the project's .editorconfig, C# files should use spaces (indent_style = space). Please replace the tab with spaces.
| switch (message) | |
| switch (message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
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 2 out of 2 changed files in this pull request and generated 2 comments.
This PR is fix for #1483
It adds a
CenterContentDependencyProperty and a new column in the Grid of TitleBar, making developer able to put content in the center area of the titlebar.Moreover, with
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"we make developer able to align the centered area more precisely, to the left, center or right edge.Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Currently there are few, less obvious alternatives.
Issue Number: #1483
What is the new behavior?
Devs are now able to put content directly in the centered area of the title bar.