2025-05-05 17:04:06 +08:00
using System.Windows.Input ;
2025-04-24 20:56:44 +08:00
using WPFluent.Extensions ;
using WPFluent.Input ;
using WPFluent.Interop ;
2025-02-10 20:53:40 +08:00
namespace WPFluent.Controls ;
/// <summary>
2025-05-05 17:04:06 +08:00
/// HCWhite navigation buttons for the window.
2025-02-10 20:53:40 +08:00
/// </summary>
[TemplatePart(Name = ElementMainGrid, Type = typeof(System.Windows.Controls.Grid))]
[TemplatePart(Name = ElementIcon, Type = typeof(System.Windows.Controls.Image))]
[TemplatePart(Name = ElementHelpButton, Type = typeof(TitleBarButton))]
[TemplatePart(Name = ElementMinimizeButton, Type = typeof(TitleBarButton))]
[TemplatePart(Name = ElementMaximizeButton, Type = typeof(TitleBarButton))]
[TemplatePart(Name = ElementRestoreButton, Type = typeof(TitleBarButton))]
[TemplatePart(Name = ElementCloseButton, Type = typeof(TitleBarButton))]
2025-05-05 17:04:06 +08:00
public class TitleBar : System . Windows . Controls . Control
2025-02-10 20:53:40 +08:00
{
private const string ElementCloseButton = "PART_CloseButton" ;
private const string ElementHelpButton = "PART_HelpButton" ;
private const string ElementIcon = "PART_Icon" ;
private const string ElementMainGrid = "PART_MainGrid" ;
private const string ElementMaximizeButton = "PART_MaximizeButton" ;
private const string ElementMinimizeButton = "PART_MinimizeButton" ;
private const string ElementRestoreButton = "PART_RestoreButton" ;
private static DpiScale ? dpiScale ;
/// <summary>
/// Identifies the <see cref="ButtonsBackground"/> dependency property.
/// </summary>
public static readonly DependencyProperty ButtonsBackgroundProperty = DependencyProperty . Register (
nameof ( ButtonsBackground ) ,
typeof ( Brush ) ,
typeof ( TitleBar ) ,
new FrameworkPropertyMetadata ( SystemColors . ControlBrush , FrameworkPropertyMetadataOptions . Inherits ) ) ;
/// <summary>
/// Identifies the <see cref="ButtonsForeground"/> dependency property.
/// </summary>
public static readonly DependencyProperty ButtonsForegroundProperty = DependencyProperty . Register (
nameof ( ButtonsForeground ) ,
typeof ( Brush ) ,
typeof ( TitleBar ) ,
new FrameworkPropertyMetadata ( SystemColors . ControlTextBrush , FrameworkPropertyMetadataOptions . Inherits ) ) ;
/// <summary>
/// Identifies the <see cref="CanMaximize"/> dependency property.
/// </summary>
public static readonly DependencyProperty CanMaximizeProperty = DependencyProperty . Register (
nameof ( CanMaximize ) ,
typeof ( bool ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( true ) ) ;
/// <summary>
/// Identifies the <see cref="CloseClicked"/> routed event.
/// </summary>
public static readonly RoutedEvent CloseClickedEvent = EventManager . RegisterRoutedEvent (
nameof ( CloseClicked ) ,
RoutingStrategy . Bubble ,
typeof ( TypedEventHandler < TitleBar , RoutedEventArgs > ) ,
typeof ( TitleBar ) ) ;
/// <summary>
/// Identifies the <see cref="CloseWindowByDoubleClickOnIcon"/> dependency property.
/// </summary>
public static readonly DependencyProperty CloseWindowByDoubleClickOnIconProperty =
DependencyProperty . Register (
nameof ( CloseWindowByDoubleClickOnIcon ) ,
typeof ( bool ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( false ) ) ;
/// <summary>
/// Identifies the <see cref="HelpClicked"/> routed event.
/// </summary>
public static readonly RoutedEvent HelpClickedEvent = EventManager . RegisterRoutedEvent (
nameof ( HelpClicked ) ,
RoutingStrategy . Bubble ,
typeof ( TypedEventHandler < TitleBar , RoutedEventArgs > ) ,
typeof ( TitleBar ) ) ;
/// <summary>
/// Identifies the <see cref="Icon"/> dependency property.
/// </summary>
public static readonly DependencyProperty IconProperty = DependencyProperty . Register (
nameof ( Icon ) ,
typeof ( IconElement ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( null ) ) ;
/// <summary>
/// Identifies the <see cref="IsMaximized"/> dependency property.
/// </summary>
public static readonly DependencyProperty IsMaximizedProperty = DependencyProperty . Register (
nameof ( IsMaximized ) ,
typeof ( bool ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( false ) ) ;
/// <summary>
/// Identifies the <see cref="MaximizeClicked"/> routed event.
/// </summary>
public static readonly RoutedEvent MaximizeClickedEvent = EventManager . RegisterRoutedEvent (
nameof ( MaximizeClicked ) ,
RoutingStrategy . Bubble ,
typeof ( TypedEventHandler < TitleBar , RoutedEventArgs > ) ,
typeof ( TitleBar ) ) ;
/// <summary>
/// Identifies the <see cref="MinimizeClicked"/> routed event.
/// </summary>
public static readonly RoutedEvent MinimizeClickedEvent = EventManager . RegisterRoutedEvent (
nameof ( MinimizeClicked ) ,
RoutingStrategy . Bubble ,
typeof ( TypedEventHandler < TitleBar , RoutedEventArgs > ) ,
typeof ( TitleBar ) ) ;
/// <summary>
/// Identifies the <see cref="ShowClose"/> dependency property.
/// </summary>
public static readonly DependencyProperty ShowCloseProperty = DependencyProperty . Register (
nameof ( ShowClose ) ,
typeof ( bool ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( true ) ) ;
/// <summary>
/// Identifies the <see cref="ShowHelp"/> dependency property.
/// </summary>
public static readonly DependencyProperty ShowHelpProperty = DependencyProperty . Register (
nameof ( ShowHelp ) ,
typeof ( bool ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( false ) ) ;
/// <summary>
/// Identifies the <see cref="ShowMaximize"/> dependency property.
/// </summary>
public static readonly DependencyProperty ShowMaximizeProperty = DependencyProperty . Register (
nameof ( ShowMaximize ) ,
typeof ( bool ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( true ) ) ;
/// <summary>
/// Identifies the <see cref="ShowMinimize"/> dependency property.
/// </summary>
public static readonly DependencyProperty ShowMinimizeProperty = DependencyProperty . Register (
nameof ( ShowMinimize ) ,
typeof ( bool ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( true ) ) ;
/// <summary>
/// Identifies the <see cref="TemplateButtonCommand"/> dependency property.
/// </summary>
public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty . Register (
nameof ( TemplateButtonCommand ) ,
typeof ( IRelayCommand ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( null ) ) ;
/// <summary>
/// Identifies the <see cref="Title"/> dependency property.
/// </summary>
public static readonly DependencyProperty TitleProperty = DependencyProperty . Register (
nameof ( Title ) ,
typeof ( string ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( null ) ) ;
/// <summary>
/// Property for <see cref="TrailingContent"/>.
/// </summary>
public static readonly DependencyProperty TrailingContentProperty = DependencyProperty . Register (
nameof ( TrailingContent ) ,
typeof ( object ) ,
typeof ( TitleBar ) ,
new PropertyMetadata ( null ) ) ;
2025-05-05 17:04:06 +08:00
private readonly TitleBarButton [ ] buttons = new TitleBarButton [ 4 ] ;
private System . Windows . Window currentWindow ;
2025-02-10 20:53:40 +08:00
2025-05-05 17:04:06 +08:00
private System . Windows . Controls . ContentPresenter icon ;
2025-02-10 20:53:40 +08:00
private DependencyObject _parentWindow ;
/// <summary>
/// Initializes a new instance of the <see cref="TitleBar"/> class and sets the default <see
/// cref="FrameworkElement.Loaded"/> event.
/// </summary>
public TitleBar ( )
{
SetValue ( TemplateButtonCommandProperty , new RelayCommand < TitleBarButtonType > ( OnTemplateButtonClick ) ) ;
dpiScale ? ? = VisualTreeHelper . GetDpi ( this ) ;
Loaded + = OnLoaded ;
Unloaded + = OnUnloaded ;
}
/// <summary>
/// Event triggered after clicking close button.
/// </summary>
public event TypedEventHandler < TitleBar , RoutedEventArgs > CloseClicked
{
add = > AddHandler ( CloseClickedEvent , value ) ;
remove = > RemoveHandler ( CloseClickedEvent , value ) ;
}
/// <summary>
/// Event triggered after clicking help button
/// </summary>
public event TypedEventHandler < TitleBar , RoutedEventArgs > HelpClicked
{
add = > AddHandler ( HelpClickedEvent , value ) ;
remove = > RemoveHandler ( HelpClickedEvent , value ) ;
}
/// <summary>
/// Event triggered after clicking maximize or restore button.
/// </summary>
public event TypedEventHandler < TitleBar , RoutedEventArgs > MaximizeClicked
{
add = > AddHandler ( MaximizeClickedEvent , value ) ;
remove = > RemoveHandler ( MaximizeClickedEvent , value ) ;
}
/// <summary>
/// Event triggered after clicking minimize button.
/// </summary>
public event TypedEventHandler < TitleBar , RoutedEventArgs > MinimizeClicked
{
add = > AddHandler ( MinimizeClickedEvent , value ) ;
remove = > RemoveHandler ( MinimizeClickedEvent , value ) ;
}
2025-07-11 09:20:23 +08:00
private void CloseWindow ( ) { currentWindow . Close ( ) ; }
2025-02-10 20:53:40 +08:00
private T GetTemplateChild < T > ( string name ) where T : DependencyObject
{
var element = GetTemplateChild ( name ) ;
2025-07-11 09:20:23 +08:00
if ( element is not T tElement )
2025-02-10 20:53:40 +08:00
{
throw new InvalidOperationException ( $"Template part '{name}' is not found or is not of type {typeof(T)}" ) ;
}
return tElement ;
}
private IntPtr HwndSourceHook ( IntPtr hwnd , int msg , IntPtr wParam , IntPtr lParam , ref bool handled )
{
var message = ( User32 . WM ) msg ;
2025-07-11 09:20:23 +08:00
if ( message
2025-02-10 20:53:40 +08:00
is not (
User32 . WM . NCHITTEST
or User32 . WM . NCMOUSELEAVE
or User32 . WM . NCLBUTTONDOWN
or User32 . WM . NCLBUTTONUP
) )
{
return IntPtr . Zero ;
}
2025-07-11 09:20:23 +08:00
foreach ( TitleBarButton button in buttons )
2025-02-10 20:53:40 +08:00
{
2025-07-11 09:20:23 +08:00
if ( ! button . ReactToHwndHook ( message , lParam , out IntPtr returnIntPtr ) )
2025-02-10 20:53:40 +08:00
{
continue ;
}
2025-05-05 17:04:06 +08:00
// 修复了有时未正确清除按钮悬停背景,导致多个按钮看起来好像悬停的问题。
2025-07-11 09:20:23 +08:00
foreach ( TitleBarButton anotherButton in buttons )
2025-02-10 20:53:40 +08:00
{
2025-07-11 09:20:23 +08:00
if ( anotherButton = = button )
2025-02-10 20:53:40 +08:00
{
continue ;
}
2025-07-11 09:20:23 +08:00
if ( anotherButton . IsHovered & & button . IsHovered )
2025-02-10 20:53:40 +08:00
{
anotherButton . RemoveHover ( ) ;
}
}
handled = true ;
return returnIntPtr ;
}
var isMouseOverHeaderContent = false ;
2025-05-05 17:04:06 +08:00
//if (message == User32.WM.NCHITTEST && (TrailingContent is UIElement))
//{
// var headerRightUiElement = TrailingContent as UIElement;
// if (headerLeftUIElement is not null)
// {
// isMouseOverHeaderContent =
// (headerRightUiElement?.IsMouseOverElement(lParam) ?? false);
// }
// else
// {
// isMouseOverHeaderContent = headerRightUiElement?.IsMouseOverElement(lParam) ?? false;
// }
//}
2025-02-10 20:53:40 +08:00
2025-07-11 09:20:23 +08:00
switch ( message )
2025-02-10 20:53:40 +08:00
{
2025-05-05 17:04:06 +08:00
case User32 . WM . NCHITTEST when CloseWindowByDoubleClickOnIcon & & icon . IsMouseOverElement ( lParam ) :
2025-02-10 20:53:40 +08:00
// Ideally, clicking on the icon should open the system menu, but when the system menu is opened manually, double-clicking on the icon does not close the window
handled = true ;
return ( IntPtr ) User32 . WM_NCHITTEST . HTSYSMENU ;
case User32 . WM . NCHITTEST when this . IsMouseOverElement ( lParam ) & & ! isMouseOverHeaderContent :
handled = true ;
return ( IntPtr ) User32 . WM_NCHITTEST . HTCAPTION ;
default :
return IntPtr . Zero ;
}
}
private void MaximizeWindow ( )
{
2025-07-11 09:20:23 +08:00
if ( ! CanMaximize )
2025-02-10 20:53:40 +08:00
{
return ;
}
2025-07-11 09:20:23 +08:00
if ( MaximizeActionOverride is not null )
2025-02-10 20:53:40 +08:00
{
2025-05-05 17:04:06 +08:00
MaximizeActionOverride ( this , currentWindow ) ;
2025-02-10 20:53:40 +08:00
return ;
}
2025-07-11 09:20:23 +08:00
if ( currentWindow . WindowState = = WindowState . Normal )
2025-02-10 20:53:40 +08:00
{
SetCurrentValue ( IsMaximizedProperty , true ) ;
2025-05-05 17:04:06 +08:00
currentWindow . SetCurrentValue ( Window . WindowStateProperty , WindowState . Maximized ) ;
2025-02-10 20:53:40 +08:00
}
else
{
SetCurrentValue ( IsMaximizedProperty , false ) ;
2025-05-05 17:04:06 +08:00
currentWindow . SetCurrentValue ( Window . WindowStateProperty , WindowState . Normal ) ;
2025-02-10 20:53:40 +08:00
}
}
private void MinimizeWindow ( )
{
2025-07-11 09:20:23 +08:00
if ( MinimizeActionOverride is not null )
2025-02-10 20:53:40 +08:00
{
2025-05-05 17:04:06 +08:00
MinimizeActionOverride ( this , currentWindow ) ;
2025-02-10 20:53:40 +08:00
return ;
}
2025-05-05 17:04:06 +08:00
currentWindow . SetCurrentValue ( Window . WindowStateProperty , WindowState . Minimized ) ;
2025-02-10 20:53:40 +08:00
}
private void OnParentWindowStateChanged ( object sender , EventArgs e )
{
2025-07-11 09:20:23 +08:00
if ( IsMaximized ! = ( currentWindow . WindowState = = WindowState . Maximized ) )
2025-02-10 20:53:40 +08:00
{
2025-05-05 17:04:06 +08:00
SetCurrentValue ( IsMaximizedProperty , currentWindow . WindowState = = WindowState . Maximized ) ;
2025-02-10 20:53:40 +08:00
}
}
2025-07-11 09:20:23 +08:00
2025-05-05 17:04:06 +08:00
/// <summary>
/// 设置窗口状态
/// </summary>
/// <param name="buttonType"></param>
2025-02-10 20:53:40 +08:00
private void OnTemplateButtonClick ( TitleBarButtonType buttonType )
{
2025-07-11 09:20:23 +08:00
switch ( buttonType )
2025-02-10 20:53:40 +08:00
{
case TitleBarButtonType . Maximize
or TitleBarButtonType . Restore :
RaiseEvent ( new RoutedEventArgs ( MaximizeClickedEvent , this ) ) ;
MaximizeWindow ( ) ;
break ;
case TitleBarButtonType . Close :
RaiseEvent ( new RoutedEventArgs ( CloseClickedEvent , this ) ) ;
CloseWindow ( ) ;
break ;
case TitleBarButtonType . Minimize :
RaiseEvent ( new RoutedEventArgs ( MinimizeClickedEvent , this ) ) ;
MinimizeWindow ( ) ;
break ;
case TitleBarButtonType . Help :
RaiseEvent ( new RoutedEventArgs ( HelpClickedEvent , this ) ) ;
break ;
}
}
private void OnUnloaded ( object sender , RoutedEventArgs e )
{
Loaded - = OnLoaded ;
Unloaded - = OnUnloaded ;
}
/// <summary>
/// Listening window hooks after rendering window content to SizeToContent support
/// </summary>
private void OnWindowContentRendered ( object sender , EventArgs e )
{
2025-07-11 09:20:23 +08:00
if ( sender is not Window window )
2025-02-10 20:53:40 +08:00
{
return ;
}
window . ContentRendered - = OnWindowContentRendered ;
var handle = new WindowInteropHelper ( window ) . Handle ;
var windowSource =
HwndSource . FromHwnd ( handle ) ? ? throw new InvalidOperationException ( "Window source is null" ) ;
windowSource . AddHook ( HwndSourceHook ) ;
}
/// <summary>
2025-05-05 17:04:06 +08:00
/// 在鼠标右键时显示 'SystemMenu'。
2025-02-10 20:53:40 +08:00
/// </summary>
private void TitleBar_MouseRightButtonUp ( object sender , MouseButtonEventArgs e )
{
var point = PointToScreen ( e . GetPosition ( this ) ) ;
2025-07-11 09:20:23 +08:00
if ( dpiScale is null )
2025-02-10 20:53:40 +08:00
{
throw new InvalidOperationException ( "dpiScale is not initialized." ) ;
}
SystemCommands . ShowSystemMenu (
_parentWindow as Window ,
new Point ( point . X / dpiScale . Value . DpiScaleX , point . Y / dpiScale . Value . DpiScaleY ) ) ;
}
protected virtual void OnLoaded ( object sender , RoutedEventArgs e )
{
2025-07-11 09:20:23 +08:00
// 添加设计时检查
if ( DesignerProperties . GetIsInDesignMode ( this ) )
return ;
currentWindow = System . Windows . Window . GetWindow ( this ) ? ? throw new InvalidOperationException ( "Window is null" ) ;
2025-05-05 17:04:06 +08:00
currentWindow . StateChanged + = OnParentWindowStateChanged ;
currentWindow . ContentRendered + = OnWindowContentRendered ;
2025-02-10 20:53:40 +08:00
}
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取单击标题栏按钮时触发的命令。
2025-02-10 20:53:40 +08:00
/// </summary>
2025-05-05 17:04:06 +08:00
internal IRelayCommand TemplateButtonCommand = > ( IRelayCommand ) GetValue ( TemplateButtonCommandProperty ) ;
2025-02-10 20:53:40 +08:00
/// <summary>
2025-05-05 17:04:06 +08:00
/// 每当应用程序代码或内部进程( 如重建布局传递) 调用OnApplyTemplate方法。
2025-02-10 20:53:40 +08:00
/// </summary>
public override void OnApplyTemplate ( )
{
base . OnApplyTemplate ( ) ;
_parentWindow = VisualTreeHelper . GetParent ( this ) ;
2025-07-11 09:20:23 +08:00
while ( _parentWindow is not null and not Window )
2025-02-10 20:53:40 +08:00
{
_parentWindow = VisualTreeHelper . GetParent ( _parentWindow ) ;
}
MouseRightButtonUp + = TitleBar_MouseRightButtonUp ;
/*_mainGrid = GetTemplateChild<System.Windows.Controls.Grid>(ElementMainGrid);*/
2025-05-05 17:04:06 +08:00
icon = GetTemplateChild < System . Windows . Controls . ContentPresenter > ( ElementIcon ) ;
2025-02-10 20:53:40 +08:00
var helpButton = GetTemplateChild < TitleBarButton > ( ElementHelpButton ) ;
var minimizeButton = GetTemplateChild < TitleBarButton > ( ElementMinimizeButton ) ;
var maximizeButton = GetTemplateChild < TitleBarButton > ( ElementMaximizeButton ) ;
var closeButton = GetTemplateChild < TitleBarButton > ( ElementCloseButton ) ;
2025-05-05 17:04:06 +08:00
buttons [ 0 ] = maximizeButton ;
buttons [ 1 ] = minimizeButton ;
buttons [ 2 ] = closeButton ;
buttons [ 3 ] = helpButton ;
2025-02-10 20:53:40 +08:00
}
2025-05-05 17:04:06 +08:00
///// <inheritdoc/>
//public Appearance.ThemeType ApplicationTheme
//{
// get => (Appearance.ThemeType)GetValue(ApplicationThemeProperty);
// set => SetValue(ApplicationThemeProperty, value);
//}
2025-02-10 20:53:40 +08:00
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置导航按钮悬停时的背景。
2025-02-10 20:53:40 +08:00
/// </summary>
[Bindable(true)]
[Category("Appearance")]
public Brush ButtonsBackground
{
get = > ( Brush ) GetValue ( ButtonsBackgroundProperty ) ;
set = > SetValue ( ButtonsBackgroundProperty , value ) ;
}
/// <summary>
/// Gets or sets the foreground of the navigation buttons.
/// </summary>
[Bindable(true)]
[Category("Appearance")]
public Brush ButtonsForeground
{
get = > ( Brush ) GetValue ( ButtonsForegroundProperty ) ;
set = > SetValue ( ButtonsForegroundProperty , value ) ;
}
/// <summary>
/// Gets or sets a value indicating whether the maximize functionality is enabled. If disabled the
/// MaximizeActionOverride action won't be called
/// </summary>
public bool CanMaximize { get = > ( bool ) GetValue ( CanMaximizeProperty ) ; set = > SetValue ( CanMaximizeProperty , value ) ; }
/// <summary>
/// Gets or sets a value indicating whether the window can be closed by double clicking on the icon
/// </summary>
public bool CloseWindowByDoubleClickOnIcon
{
get = > ( bool ) GetValue ( CloseWindowByDoubleClickOnIconProperty ) ;
set = > SetValue ( CloseWindowByDoubleClickOnIconProperty , value ) ;
}
/// <summary>
/// Gets or sets the titlebar icon.
/// </summary>
public IconElement Icon { get = > ( IconElement ) GetValue ( IconProperty ) ; set = > SetValue ( IconProperty , value ) ; }
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取一个值,该值指示当前窗口是否最大化。
2025-02-10 20:53:40 +08:00
/// </summary>
public bool IsMaximized
{
get = > ( bool ) GetValue ( IsMaximizedProperty ) ;
internal set = > SetValue ( IsMaximizedProperty , value ) ;
}
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置单击“最大化”按钮时应执行的 <see cref=“Action”/>。
2025-02-10 20:53:40 +08:00
/// </summary>
public Action < TitleBar , System . Windows . Window > MaximizeActionOverride { get ; set ; }
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置在单击 Minimize 按钮时应执行的 <see cref=“Action”/> 内容。
2025-02-10 20:53:40 +08:00
/// </summary>
public Action < TitleBar , System . Windows . Window > MinimizeActionOverride { get ; set ; }
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置一个值,该值指示是否显示关闭按钮。
2025-02-10 20:53:40 +08:00
/// </summary>
public bool ShowClose { get = > ( bool ) GetValue ( ShowCloseProperty ) ; set = > SetValue ( ShowCloseProperty , value ) ; }
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置一个值,该值指示是否显示 help 按钮
2025-02-10 20:53:40 +08:00
/// </summary>
public bool ShowHelp { get = > ( bool ) GetValue ( ShowHelpProperty ) ; set = > SetValue ( ShowHelpProperty , value ) ; }
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置一个值,该值指示是否显示 maximize (最大化) 按钮。
2025-02-10 20:53:40 +08:00
/// </summary>
public bool ShowMaximize
{
get = > ( bool ) GetValue ( ShowMaximizeProperty ) ;
set = > SetValue ( ShowMaximizeProperty , value ) ;
}
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置一个值,该值指示是否显示 minimize (最小化) 按钮。
2025-02-10 20:53:40 +08:00
/// </summary>
public bool ShowMinimize
{
get = > ( bool ) GetValue ( ShowMinimizeProperty ) ;
set = > SetValue ( ShowMinimizeProperty , value ) ;
}
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置显示在左侧的标题。
2025-02-10 20:53:40 +08:00
/// </summary>
public string Title { get = > ( string ) GetValue ( TitleProperty ) ; set = > SetValue ( TitleProperty , value ) ; }
/// <summary>
2025-05-05 17:04:06 +08:00
/// 获取或设置在右侧显示的内容 <see cref="TitleBar"/>.
2025-02-10 20:53:40 +08:00
/// </summary>
public object TrailingContent
{
get = > GetValue ( TrailingContentProperty ) ;
set = > SetValue ( TrailingContentProperty , value ) ;
}
2025-05-05 17:04:06 +08:00
}