diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs
index 67c2d7478..22e4dee0d 100644
--- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs
+++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs
@@ -66,6 +66,16 @@ public partial class TitleBar : System.Windows.Controls.Control, IThemeControl
new PropertyMetadata(null)
);
+ ///
+ /// Property for .
+ ///
+ public static readonly DependencyProperty CenterContentProperty = DependencyProperty.Register(
+ nameof(CenterContent),
+ typeof(object),
+ typeof(TitleBar),
+ new PropertyMetadata(null)
+ );
+
///
/// Property for .
///
@@ -233,6 +243,15 @@ public object? Header
set => SetValue(HeaderProperty, value);
}
+ ///
+ /// Gets or sets the content displayed in the center of the .
+ ///
+ public object? CenterContent
+ {
+ get => GetValue(CenterContentProperty);
+ set => SetValue(CenterContentProperty, value);
+ }
+
///
/// Gets or sets the content displayed in right side of the .
///
@@ -685,20 +704,15 @@ or PInvoke.WM_NCLBUTTONUP
if (message == PInvoke.WM_NCHITTEST)
{
- if (TrailingContent is UIElement || Header is UIElement)
+ 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;
- if (Header is UIElement headerLeftUIElement && headerLeftUIElement != _titleBlock)
- {
- isMouseOverHeaderContent =
- headerLeftUIElement.IsMouseOverElement(lParam)
- || (headerRightUiElement?.IsMouseOverElement(lParam) ?? false);
- }
- else
- {
- isMouseOverHeaderContent = headerRightUiElement?.IsMouseOverElement(lParam) ?? false;
- }
+ isMouseOverHeaderContent = (headerLeftUIElement is not null && headerLeftUIElement != _titleBlock && headerLeftUIElement.IsMouseOverElement(lParam))
+ || (headerCenterUIElement?.IsMouseOverElement(lParam) ?? false)
+ || (headerRightUiElement?.IsMouseOverElement(lParam) ?? false);
}
htResult = GetWindowBorderHitTestResult(hwnd, lParam);
diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml
index 831097e3a..97f5de643 100644
--- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml
+++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml
@@ -137,6 +137,7 @@
+
@@ -145,15 +146,22 @@
HorizontalAlignment="Left"
Content="{TemplateBinding Header}" />
-
+
+
+
+