HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonWindow

BinaryRibbonWindow

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Controls.Office

A custom Window class that provides Office emulating window display.

public partial class BinaryRibbonWindow : Window

Inherits from / implements: Window

Remarks

How this control works. The window draws its own frame: the title bar, the caption buttons, the quick access toolbar and the border are all in its template, and the whole window is client area. Its window procedure answers WM_NCCALCSIZE to give the caption rows to the client, WM_NCHITTEST so that the template's title bar drags and its edges resize, and asks for the rows it took back to be repainted; while it draws its own chrome it also tells the desktop window manager not to draw a system caption over it. The handle can change. A window handle can be recreated (a state change can do it), so the window procedure hook and the frame settings are applied to each handle as it appears, not once per window. Icons set with WM_SETICON go through to default processing, which is what keeps the taskbar icon across maximise and restore. Skins and backdrop. The frame takes its colours from the ribbon's skin resources; under a Fluent skin on Windows 11 it can let Mica show through and tells the frame whether the skin is light or dark. The ribbon display options button in the title bar is in the DisplayOptions partial. Right to left mirrors the window's content while the window itself stays left to right, so its handle is never mirrored.

Members at a glance

BinaryRibbonWindowInitializes a new instance of the BinaryRibbonWindow class.
ApplicationMenuButtonRenderingStyleGets or sets the application menu button rendering style.
CloseWindowGets the CloseWindow routed UI command instance.
CurrentlyRenderingGlassOnNCAreaGets or sets a value indicating whether currently extending glass on to the Window frame.
EnableDropShadowEffectOnWindowControlButtonsGets or sets a value indicating whether to enable drop shadow effect on window control buttons - i.e. Minimize, Maximize and Close buttons.
GlassCaptionBrushGets the brush the glass template fills its caption area with when the operating system has no material of its own to put there, or null when it has.
IsFlowDirectionRightToLeftGets or sets whether the window is laid out right to left, for Arabic, Hebrew, Persian and the other right-to-left languages.
IsRibbonWindowActiveAndCurrentGets or sets a value indicating whether this instance is active and current.
IsWindowControlButtonsVisibleGets or sets a value indicating whether the window control buttons are visible or not - i.e. the Minimize, Maximise and Close button.
MaximizeWindowGets the Maximize routed UI command instance.
MinimizeWindowGets the MinimizeWindow routed UI command instance.
QATPanelHeightThe height of the quick access toolbar panel.
QATPanelMarginThe margin left around the quick access toolbar panel.
RenderGlassIfOSSupportsGets or sets a value indicating whether to render Vista / Windows 7 Aero glass in the non-client areas, if the current OS supports.
ScaleTransformScaleXAndScaleYGets or sets the scale transform's scale X and scale Y values.
TitleBarMarginThe margin left around the title bar, which is how the caption is kept clear of the window's own chrome.
TitleBrushGets or sets the Window title brush.
WindowBorderEdgeRenderingModeGets or sets the window border edge rendering mode.
WindowTitleBarBackgroundRenderingStyleGets or sets the window title bar background rendering style.
ArrangeOverridePlaces the children within the space this element was given, and reports the space it actually used.
GetIsHitTestVisibleInChromeGets whether an element in the window's caption takes the pointer rather than letting the window be dragged.
OnApplyTemplateWhen overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate.
OnClosedCalled when the window has closed; stops listening for skin changes.
OnContentChangedCalled when the window's content changes; new content takes the window's direction.
OnDpiChangedRaises the DpiChanged event, and puts the glass frame back at the new scale.
OnSizeChangedCalled when the window is resized, which is where the ribbon is told to reconsider how much of itself it can show.
OnSourceInitializedRaises the SourceInitialized event. BinaryRibbonWindow overrides it so the control's own handling runs alongside the base behavior.
OnStateChangedRaises the StateChanged event. BinaryRibbonWindow overrides it so the control's own handling runs alongside the base behavior.
SetIsHitTestVisibleInChromeSets whether an element in the window's caption takes the pointer rather than letting the window be dragged.
WndProcProcesses the Windows messages sent to this control's window.
ApplicationMenuButtonRenderingStylePropertyIdentifies the ApplicationMenuButtonRenderingStyle dependency property.
CurrentlyRenderingGlassOnNCAreaPropertyCurrentlyRenderingGlassOnNCAreaProperty property.
EnableDropShadowEffectOnWindowControlButtonsPropertyEnableDropShadowEffectOnWindowControlButtonsProperty property.
GlassCaptionBrushPropertyIdentifies the GlassCaptionBrush dependency property.
IsFlowDirectionRightToLeftPropertyIdentifies the IsFlowDirectionRightToLeft dependency property.
IsHitTestVisibleInChromePropertyIdentifies the IsHitTestVisibleInChrome attached property.
IsWindowActiveAndCurrentPropertyIsWindowActiveAndCurrentProperty property.
IsWindowControlButtonsVisiblePropertyIsWindowControlButtonsVisibleProperty property.
QATPanelHeightPropertyIdentifies the QATPanelHeight dependency property.
QATPanelMarginPropertyIdentifies the QATPanelMargin dependency property.
RenderGlassIfOSSupportsPropertyRenderGlassIfOSSupportsProperty property.
ScaleTransformScaleXAndScaleYPropertyIdentifies the ScaleTransformScaleXAndScaleY dependency property.
TitleBarMarginPropertyIdentifies the TitleBarMargin dependency property.
TitleBrushPropertyTitleBrushProperty property.
WindowBorderEdgeRenderingModePropertyWindowBorderEdgeRenderingModeProperty property.
WindowTitleBarBackgroundRenderingStylePropertyIdentifies the WindowTitleBarBackgroundRenderingStyle dependency property.

Constructors

BinaryRibbonWindow

public BinaryRibbonWindow() : base()

Initializes a new instance of the BinaryRibbonWindow class.

Properties

ApplicationMenuButtonRenderingStyle

public ApplicationMenuButtonStyle ApplicationMenuButtonRenderingStyle

Gets or sets the application menu button rendering style.

Refer to the ApplicationMenuButtonStyle

CloseWindow

public static RoutedUICommand CloseWindow

Gets the CloseWindow routed UI command instance.

CurrentlyRenderingGlassOnNCArea

public bool CurrentlyRenderingGlassOnNCArea

Gets or sets a value indicating whether currently extending glass on to the Window frame.

EnableDropShadowEffectOnWindowControlButtons

public bool EnableDropShadowEffectOnWindowControlButtons

Gets or sets a value indicating whether to enable drop shadow effect on window control buttons - i.e. Minimize, Maximize and Close buttons.

GlassCaptionBrush

public Brush GlassCaptionBrush

Gets the brush the glass template fills its caption area with when the operating system has no material of its own to put there, or null when it has.

Null on Vista and Windows 7, where the DWM blurs what is behind the frame, and null on Windows 11, where Mica draws the area itself and a brush over it would hide it. Set to the user's window colour on Windows 8 to 10, where an extended frame is otherwise black.

IsFlowDirectionRightToLeft

public bool IsFlowDirectionRightToLeft

Gets or sets whether the window is laid out right to left, for Arabic, Hebrew, Persian and the other right-to-left languages.

Value. true for right to left. The default is false .

Everything in the window is laid out right to left: the caption buttons move to the left with Close outermost, the ribbon runs from the right with the application menu at the right-hand end, and the application's own content follows - the window sets FlowDirection on its Content, and takes it off again when this is turned off or the content is replaced. Use this rather than setting FlowDirection on the window itself: that mirrors the window handle as well, and this window draws its own caption. Glass is not drawn while the window is right to left, because a glass frame's caption buttons are the system's and stay at the right; it comes back when the window returns to left to right, if RenderGlassIfOSSupports is still set.

IsRibbonWindowActiveAndCurrent

public bool IsRibbonWindowActiveAndCurrent

Gets or sets a value indicating whether this instance is active and current.

IsWindowControlButtonsVisible

public bool IsWindowControlButtonsVisible

Gets or sets a value indicating whether the window control buttons are visible or not - i.e. the Minimize, Maximise and Close button.

MaximizeWindow

public static RoutedUICommand MaximizeWindow

Gets the Maximize routed UI command instance.

MinimizeWindow

public static RoutedUICommand MinimizeWindow

Gets the MinimizeWindow routed UI command instance.

QATPanelHeight

public double QATPanelHeight

The height of the quick access toolbar panel.

QATPanelMargin

public Thickness QATPanelMargin

The margin left around the quick access toolbar panel.

RenderGlassIfOSSupports

public bool RenderGlassIfOSSupports

Gets or sets a value indicating whether to render Vista / Windows 7 Aero glass in the non-client areas, if the current OS supports.

For this property to work, the OS will need to support Aero Glass, also the DWM composition must be currently enabled.

ScaleTransformScaleXAndScaleY

public double ScaleTransformScaleXAndScaleY

Gets or sets the scale transform's scale X and scale Y values.

When wanting to perform a layout transfor, please use this property to set the desired Scale X and Y values.

TitleBarMargin

public Thickness TitleBarMargin

The margin left around the title bar, which is how the caption is kept clear of the window's own chrome.

TitleBrush

public Brush TitleBrush

Gets or sets the Window title brush.

WindowBorderEdgeRenderingMode

public RibbonWindowBorder.CornerStyle WindowBorderEdgeRenderingMode

Gets or sets the window border edge rendering mode.

WindowTitleBarBackgroundRenderingStyle

public WindowTitleBarBackgroundRenderingStyle WindowTitleBarBackgroundRenderingStyle

Gets or sets the window title bar background rendering style.

Please refer to WindowTitleBarBackgroundRenderingStyle

Methods

ArrangeOverride

protected override Size ArrangeOverride(Size bounds)

Places the children within the space this element was given, and reports the space it actually used.

GetIsHitTestVisibleInChrome

public static bool GetIsHitTestVisibleInChrome(DependencyObject element)

Gets whether an element in the window's caption takes the pointer rather than letting the window be dragged.

element
The element.

Returns. true if the element answers clicks of its own.

OnApplyTemplate

public override void OnApplyTemplate()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate.

OnClosed

protected override void OnClosed(EventArgs e)

Called when the window has closed; stops listening for skin changes.

e
Not used.

OnContentChanged

protected override void OnContentChanged(object oldContent, object newContent)

Called when the window's content changes; new content takes the window's direction.

oldContent
The content that was there.
newContent
The content now there.

OnDpiChanged

protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)

Raises the DpiChanged event, and puts the glass frame back at the new scale.

oldDpi
The scale before the change.
newDpi
The scale after it.
The frame is measured in physical pixels, so dragging the window to a display at a different scale leaves it the wrong size until it is worked out again.

OnSizeChanged

protected virtual void OnSizeChanged(object sender, SizeChangedEventArgs e)

Called when the window is resized, which is where the ribbon is told to reconsider how much of itself it can show.

sender
The window.
e
The old and new sizes.

OnSourceInitialized

protected override void OnSourceInitialized(EventArgs e)

Raises the SourceInitialized event. BinaryRibbonWindow overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnStateChanged

protected override void OnStateChanged(EventArgs e)

Raises the StateChanged event. BinaryRibbonWindow overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

SetIsHitTestVisibleInChrome

public static void SetIsHitTestVisibleInChrome(DependencyObject element, bool value)

Sets whether an element in the window's caption takes the pointer rather than letting the window be dragged.

element
The element.
value
true if the element answers clicks of its own.
Only needed for something that is not already a control the user operates: a button, a text box, a menu or a tab in the caption is left alone without this.

WndProc

protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool resultFromExecution)

Processes the Windows messages sent to this control's window.

Fields

ApplicationMenuButtonRenderingStyleProperty

public static readonly DependencyProperty ApplicationMenuButtonRenderingStyleProperty

Identifies the ApplicationMenuButtonRenderingStyle dependency property.

CurrentlyRenderingGlassOnNCAreaProperty

public static DependencyProperty CurrentlyRenderingGlassOnNCAreaProperty

CurrentlyRenderingGlassOnNCAreaProperty property.

EnableDropShadowEffectOnWindowControlButtonsProperty

public static readonly DependencyProperty EnableDropShadowEffectOnWindowControlButtonsProperty

EnableDropShadowEffectOnWindowControlButtonsProperty property.

GlassCaptionBrushProperty

public static readonly DependencyProperty GlassCaptionBrushProperty

Identifies the GlassCaptionBrush dependency property.

IsFlowDirectionRightToLeftProperty

public static readonly DependencyProperty IsFlowDirectionRightToLeftProperty

Identifies the IsFlowDirectionRightToLeft dependency property.

IsHitTestVisibleInChromeProperty

public static readonly DependencyProperty IsHitTestVisibleInChromeProperty

Identifies the IsHitTestVisibleInChrome attached property.

IsWindowActiveAndCurrentProperty

public static readonly DependencyProperty IsWindowActiveAndCurrentProperty

IsWindowActiveAndCurrentProperty property.

IsWindowControlButtonsVisibleProperty

public static readonly DependencyProperty IsWindowControlButtonsVisibleProperty

IsWindowControlButtonsVisibleProperty property.

QATPanelHeightProperty

public static readonly DependencyProperty QATPanelHeightProperty

Identifies the QATPanelHeight dependency property.

QATPanelMarginProperty

public static readonly DependencyProperty QATPanelMarginProperty

Identifies the QATPanelMargin dependency property.

RenderGlassIfOSSupportsProperty

public static readonly DependencyProperty RenderGlassIfOSSupportsProperty

RenderGlassIfOSSupportsProperty property.

ScaleTransformScaleXAndScaleYProperty

public static readonly DependencyProperty ScaleTransformScaleXAndScaleYProperty

Identifies the ScaleTransformScaleXAndScaleY dependency property.

TitleBarMarginProperty

public static readonly DependencyProperty TitleBarMarginProperty

Identifies the TitleBarMargin dependency property.

TitleBrushProperty

public static DependencyProperty TitleBrushProperty

TitleBrushProperty property.

WindowBorderEdgeRenderingModeProperty

public static readonly DependencyProperty WindowBorderEdgeRenderingModeProperty

WindowBorderEdgeRenderingModeProperty property.

WindowTitleBarBackgroundRenderingStyleProperty

public static readonly DependencyProperty WindowTitleBarBackgroundRenderingStyleProperty

Identifies the WindowTitleBarBackgroundRenderingStyle dependency property.