Table of Contents

Class TitleBar

Namespace
Wpf.Ui.Controls
Assembly
Wpf.Ui.dll

Custom navigation buttons for the window.

[TemplatePart(Name = "PART_MainGrid", Type = typeof(Grid))]
[TemplatePart(Name = "PART_Icon", Type = typeof(Image))]
[TemplatePart(Name = "PART_HelpButton", Type = typeof(TitleBarButton))]
[TemplatePart(Name = "PART_MinimizeButton", Type = typeof(TitleBarButton))]
[TemplatePart(Name = "PART_MaximizeButton", Type = typeof(TitleBarButton))]
[TemplatePart(Name = "PART_RestoreButton", Type = typeof(TitleBarButton))]
[TemplatePart(Name = "PART_CloseButton", Type = typeof(TitleBarButton))]
public class TitleBar : Control, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IQueryAmbient, IThemeControl
Inheritance
TitleBar
Implements
Inherited Members

Constructors

TitleBar()

Initializes a new instance of the TitleBar class and sets the default Loaded event.

public TitleBar()

Fields

ApplicationThemeProperty

Identifies the ApplicationTheme dependency property.

public static readonly DependencyProperty ApplicationThemeProperty

Field Value

DependencyProperty

ButtonsBackgroundProperty

Identifies the ButtonsBackground dependency property.

public static readonly DependencyProperty ButtonsBackgroundProperty

Field Value

DependencyProperty

ButtonsForegroundProperty

Identifies the ButtonsForeground dependency property.

public static readonly DependencyProperty ButtonsForegroundProperty

Field Value

DependencyProperty

CanMaximizeProperty

Identifies the CanMaximize dependency property.

public static readonly DependencyProperty CanMaximizeProperty

Field Value

DependencyProperty

CloseClickedEvent

Identifies the CloseClicked routed event.

public static readonly RoutedEvent CloseClickedEvent

Field Value

RoutedEvent

CloseWindowByDoubleClickOnIconProperty

Identifies the CloseWindowByDoubleClickOnIcon dependency property.

public static readonly DependencyProperty CloseWindowByDoubleClickOnIconProperty

Field Value

DependencyProperty

ForceShutdownProperty

Identifies the ForceShutdown dependency property.

public static readonly DependencyProperty ForceShutdownProperty

Field Value

DependencyProperty

HeaderProperty

Identifies the Header dependency property.

public static readonly DependencyProperty HeaderProperty

Field Value

DependencyProperty

HelpClickedEvent

Identifies the HelpClicked routed event.

public static readonly RoutedEvent HelpClickedEvent

Field Value

RoutedEvent

IconProperty

Identifies the Icon dependency property.

public static readonly DependencyProperty IconProperty

Field Value

DependencyProperty

IsMaximizedProperty

Identifies the IsMaximized dependency property.

public static readonly DependencyProperty IsMaximizedProperty

Field Value

DependencyProperty

MaximizeClickedEvent

Identifies the MaximizeClicked routed event.

public static readonly RoutedEvent MaximizeClickedEvent

Field Value

RoutedEvent

MinimizeClickedEvent

Identifies the MinimizeClicked routed event.

public static readonly RoutedEvent MinimizeClickedEvent

Field Value

RoutedEvent

ShowCloseProperty

Identifies the ShowClose dependency property.

public static readonly DependencyProperty ShowCloseProperty

Field Value

DependencyProperty

ShowHelpProperty

Identifies the ShowHelp dependency property.

public static readonly DependencyProperty ShowHelpProperty

Field Value

DependencyProperty

ShowMaximizeProperty

Identifies the ShowMaximize dependency property.

public static readonly DependencyProperty ShowMaximizeProperty

Field Value

DependencyProperty

ShowMinimizeProperty

Identifies the ShowMinimize dependency property.

public static readonly DependencyProperty ShowMinimizeProperty

Field Value

DependencyProperty

TemplateButtonCommandProperty

Identifies the TemplateButtonCommand dependency property.

public static readonly DependencyProperty TemplateButtonCommandProperty

Field Value

DependencyProperty

TitleProperty

Identifies the Title dependency property.

public static readonly DependencyProperty TitleProperty

Field Value

DependencyProperty

Properties

ApplicationTheme

Gets the theme that is currently set.

public ApplicationTheme ApplicationTheme { get; set; }

Property Value

ApplicationTheme

ButtonsBackground

Gets or sets the background of the navigation buttons when hovered.

[Bindable(true)]
public Brush ButtonsBackground { get; set; }

Property Value

Brush

ButtonsForeground

Gets or sets the foreground of the navigation buttons.

[Bindable(true)]
public Brush ButtonsForeground { get; set; }

Property Value

Brush

CanMaximize

Gets or sets a value indicating whether the maximize functionality is enabled. If disabled the MaximizeActionOverride action won't be called

public bool CanMaximize { get; set; }

Property Value

bool

CloseWindowByDoubleClickOnIcon

Gets or sets a value indicating whether the window can be closed by double clicking on the icon

public bool CloseWindowByDoubleClickOnIcon { get; set; }

Property Value

bool

ForceShutdown

Gets or sets a value indicating whether the controls affect main application window.

public bool ForceShutdown { get; set; }

Property Value

bool

Header

Gets or sets the content displayed in the TitleBar.

public object? Header { get; set; }

Property Value

object

Icon

Gets or sets the titlebar icon.

public IconElement? Icon { get; set; }

Property Value

IconElement

IsMaximized

Gets a value indicating whether the current window is maximized.

public bool IsMaximized { get; }

Property Value

bool

MaximizeActionOverride

Gets or sets the Action that should be executed when the Maximize button is clicked."/>

public Action<TitleBar, Window>? MaximizeActionOverride { get; set; }

Property Value

Action<TitleBar, Window>

MinimizeActionOverride

Gets or sets what Action should be executed when the Minimize button is clicked.

public Action<TitleBar, Window>? MinimizeActionOverride { get; set; }

Property Value

Action<TitleBar, Window>

ShowClose

Gets or sets a value indicating whether to show the close button.

public bool ShowClose { get; set; }

Property Value

bool

ShowHelp

Gets or sets a value indicating whether to show the help button

public bool ShowHelp { get; set; }

Property Value

bool

ShowMaximize

Gets or sets a value indicating whether to show the maximize button.

public bool ShowMaximize { get; set; }

Property Value

bool

ShowMinimize

Gets or sets a value indicating whether to show the minimize button.

public bool ShowMinimize { get; set; }

Property Value

bool

TemplateButtonCommand

Gets the command triggered when clicking the titlebar button.

public IRelayCommand TemplateButtonCommand { get; }

Property Value

IRelayCommand

Title

Gets or sets title displayed on the left.

public string? Title { get; set; }

Property Value

string

Methods

OnApplyTemplate()

Invoked whenever application code or an internal process, such as a rebuilding layout pass, calls the ApplyTemplate method.

public override void OnApplyTemplate()

OnInitialized(EventArgs)

Raises the Initialized event. This method is invoked whenever IsInitialized is set to true internally.

protected override void OnInitialized(EventArgs e)

Parameters

e EventArgs

The RoutedEventArgs that contains the event data.

OnLoaded(object, RoutedEventArgs)

protected virtual void OnLoaded(object sender, RoutedEventArgs e)

Parameters

sender object
e RoutedEventArgs

OnThemeChanged(ApplicationTheme, Color)

This virtual method is triggered when the app's theme changes.

protected virtual void OnThemeChanged(ApplicationTheme currentApplicationTheme, Color systemAccent)

Parameters

currentApplicationTheme ApplicationTheme
systemAccent Color

Events

CloseClicked

Event triggered after clicking close button.

public event TypedEventHandler<TitleBar, RoutedEventArgs> CloseClicked

Event Type

TypedEventHandler<TitleBar, RoutedEventArgs>

HelpClicked

Event triggered after clicking help button

public event TypedEventHandler<TitleBar, RoutedEventArgs> HelpClicked

Event Type

TypedEventHandler<TitleBar, RoutedEventArgs>

MaximizeClicked

Event triggered after clicking maximize or restore button.

public event TypedEventHandler<TitleBar, RoutedEventArgs> MaximizeClicked

Event Type

TypedEventHandler<TitleBar, RoutedEventArgs>

MinimizeClicked

Event triggered after clicking minimize button.

public event TypedEventHandler<TitleBar, RoutedEventArgs> MinimizeClicked

Event Type

TypedEventHandler<TitleBar, RoutedEventArgs>