HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonWindow

BinaryRibbonWindow

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

The window a ribbon application lives in: it gives its caption to a BinaryRibbonBarPanel - title, application button and quick access toolbar – and draws caption buttons, frame and corners to match the ribbon's skin.

public partial class BinaryRibbonWindow : Window

Inherits from / implements: Window

Remarks

Derive the main window from it and put the ribbon first in its content, docked at the top. The window has no system caption: the ribbon draws the title (BinaryRibbonBarPanel.TitleText, not Window.Title) and the window draws minimise, maximise and close at the right. The caption still drags the window, a double-click maximises it and the edges resize it; a control in the caption that is not a button, text box, menu or tab takes clicks once SetIsHitTestVisibleInChrome is set on it.

Appearance

Colours follow BinaryRibbonBuiltInSkinController.Skin. WindowBorderEdgeRenderingMode rounds the corners, RenderGlassIfOSSupports lets the operating system's glass or Mica show through the frame, and IsFlowDirectionRightToLeft lays the whole window out right to left. In a ribbon window Alt or F10 shows the ribbon's key tips (BinaryKeyTip).

Examples

The code-behind of a ribbon window; its XAML is shown under BinaryRibbonBarPanel.

using Binarymission.WPF.Controls.Office;

public partial class MainWindow : BinaryRibbonWindow
{
    public MainWindow()
    {
        InitializeComponent();
        BinaryRibbonBuiltInSkinController.Skin = RibbonSkin.FluentWhite;
        WindowBorderEdgeRenderingMode = RibbonWindowBorder.CornerStyle.Top;
    }
}

See also

Members at a glance

Constructors
BinaryRibbonWindowCreates a ribbon window; give it a BinaryRibbonBarPanel as the first of its content.
Properties
ApplicationMenuButtonRenderingStyleGets or sets how the ribbon's application button is drawn.
CloseWindowGets the command that closes the window, used by the caption's close button.
CurrentlyRenderingGlassOnNCAreaGets whether the operating system's glass is being drawn in the frame.
EnableDropShadowEffectOnWindowControlButtonsGets or sets whether a caption button casts a faint shadow while the pointer is over it.
GlassCaptionBrushGets the fill the glass template paints its caption with where the operating system has no material of its own.
IsFlowDirectionRightToLeftGets or sets whether the window is laid out right to left, for Arabic, Hebrew, Persian and the other right-to-left languages.
IsRibbonWindowActiveAndCurrentGets whether the window is the active window, which its caption and frame colours follow.
IsWindowControlButtonsVisibleGets or sets whether the minimise, maximise and close buttons are shown in the caption.
MaximizeWindowGets the command that maximises the window, or restores it when it is maximised.
MinimizeWindowGets the command that minimises the window, used by the caption's minimise button.
QATPanelHeightGets or sets the height of the quick access toolbar in the caption.
QATPanelMarginGets or sets the margin round the quick access toolbar in the caption.
RenderGlassIfOSSupportsGets or sets whether the operating system's own frame material – Aero glass, or Mica on Windows 11 – shows through the window's frame and caption.
ScaleTransformScaleXAndScaleYGets or sets a zoom factor for the ribbon and the caption row, for a ribbon drawn larger or smaller than the rest of the window.
TitleBarMarginGets or sets the margin round the ribbon's title while a contextual tab set is on show.
TitleBrushGets the brush the ribbon's title is drawn with, set from the skin and the window's state.
WindowBorderEdgeRenderingModeGets or sets which corners of the window are rounded.
WindowTitleBarBackgroundRenderingStyleGets or sets a title bar style that the built-in templates do not read.
Methods
ArrangeOverrideArranges the window's template across the whole window, caption included.
GetIsHitTestVisibleInChromeGets whether an element in the caption takes clicks rather than letting the window be dragged.
OnApplyTemplateTakes the template's parts, sets up the ribbon display options button and applies ScaleTransformScaleXAndScaleY.
OnClosedStops following skin changes when the window closes.
OnContentChangedGives new content the window's direction when IsFlowDirectionRightToLeft is set.
OnDpiChangedFits the glass frame to the new display scale when the window moves to another monitor.
OnSizeChangedCalled when the window is resized; the base implementation reshapes the window's rounded outline and updates the title colour. Call it when overriding.
OnSourceInitializedStarts following skin changes and sets up the frame once the window has its handle.
OnStateChangedRedraws the frame after the window is maximised or restored.
SetIsHitTestVisibleInChromeSets whether an element in the caption takes clicks rather than letting the window be dragged.
WndProcHandles the window messages that let the window draw its own caption: frame size, hit testing, activation, text changes and desktop composition.
Fields
ApplicationMenuButtonRenderingStylePropertyIdentifies the ApplicationMenuButtonRenderingStyle dependency property.
CurrentlyRenderingGlassOnNCAreaPropertyIdentifies the CurrentlyRenderingGlassOnNCArea dependency property.
EnableDropShadowEffectOnWindowControlButtonsPropertyIdentifies the EnableDropShadowEffectOnWindowControlButtons dependency property.
GlassCaptionBrushPropertyIdentifies the GlassCaptionBrush dependency property.
IsFlowDirectionRightToLeftPropertyIdentifies the IsFlowDirectionRightToLeft dependency property.
IsHitTestVisibleInChromePropertyIdentifies the IsHitTestVisibleInChrome attached property.
IsWindowActiveAndCurrentPropertyIdentifies the IsRibbonWindowActiveAndCurrent dependency property.
IsWindowControlButtonsVisiblePropertyIdentifies the IsWindowControlButtonsVisible dependency property.
QATPanelHeightPropertyIdentifies the QATPanelHeight dependency property.
QATPanelMarginPropertyIdentifies the QATPanelMargin dependency property.
RenderGlassIfOSSupportsPropertyIdentifies the RenderGlassIfOSSupports dependency property.
ScaleTransformScaleXAndScaleYPropertyIdentifies the ScaleTransformScaleXAndScaleY dependency property.
TitleBarMarginPropertyIdentifies the TitleBarMargin dependency property.
TitleBrushPropertyIdentifies the TitleBrush dependency property.
WindowBorderEdgeRenderingModePropertyIdentifies the WindowBorderEdgeRenderingMode dependency property.
WindowTitleBarBackgroundRenderingStylePropertyIdentifies the WindowTitleBarBackgroundRenderingStyle dependency property.

Constructors

BinaryRibbonWindow

public BinaryRibbonWindow() : base()

Creates a ribbon window; give it a BinaryRibbonBarPanel as the first of its content.

Properties

ApplicationMenuButtonRenderingStyle

public ApplicationMenuButtonStyle ApplicationMenuButtonRenderingStyle

Gets or sets how the ribbon's application button is drawn.

Value
The default is ApplicationMenuButtonStyle.GlassyWithCustomBackgroundFill.
Remarks

A change swaps the button's resources in the application's resources, so it applies to every ribbon in the application and needs a running Application.

CloseWindow static

public static RoutedUICommand CloseWindow

Gets the command that closes the window, used by the caption's close button.

CurrentlyRenderingGlassOnNCArea

public bool CurrentlyRenderingGlassOnNCArea

Gets whether the operating system's glass is being drawn in the frame.

Value
true while RenderGlassIfOSSupports is set and in effect.

EnableDropShadowEffectOnWindowControlButtons

public bool EnableDropShadowEffectOnWindowControlButtons

Gets or sets whether a caption button casts a faint shadow while the pointer is over it.

Value
The default is true.

GlassCaptionBrush

public Brush GlassCaptionBrush

Gets the fill the glass template paints its caption with where the operating system has no material of its own.

Value
null while glass is off, and on Windows Vista, 7 and 11, whose blur or Mica shows through; on Windows 8 to 10 (or when a skin declines Mica), the skin's caption fill or else the user's window colour.

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
The default is false.
Remarks

The caption buttons move to the left with Close outermost, the ribbon runs from the right with the application button at the right-hand end, and the window's ContentControl.Content is given FlowDirection.RightToLeft – taken off again when this is cleared or the content replaced. Use this rather than FrameworkElement.FlowDirection on the window itself, which would mirror the window handle as well.

Glass is not drawn while the window is right to left; it comes back on return to left to right if RenderGlassIfOSSupports is still set.

Example
IsFlowDirectionRightToLeft = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft;

IsRibbonWindowActiveAndCurrent

public bool IsRibbonWindowActiveAndCurrent

Gets whether the window is the active window, which its caption and frame colours follow.

Value
The default is false until the window is first activated.

IsWindowControlButtonsVisible

public bool IsWindowControlButtonsVisible

Gets or sets whether the minimise, maximise and close buttons are shown in the caption.

Value
The default is true.
Remarks

Hiding them leaves Alt+F4 and the taskbar to close the window.

MaximizeWindow static

public static RoutedUICommand MaximizeWindow

Gets the command that maximises the window, or restores it when it is maximised.

MinimizeWindow static

public static RoutedUICommand MinimizeWindow

Gets the command that minimises the window, used by the caption's minimise button.

QATPanelHeight

public double QATPanelHeight

Gets or sets the height of the quick access toolbar in the caption.

Value
In logical pixels. The default is 22, and 17 while the window is maximised.

QATPanelMargin

public Thickness QATPanelMargin

Gets or sets the margin round the quick access toolbar in the caption.

Value
In logical pixels. The default is -16,2,0,0, and -16,6,0,0 while the window is maximised.

RenderGlassIfOSSupports

public bool RenderGlassIfOSSupports

Gets or sets whether the operating system's own frame material – Aero glass, or Mica on Windows 11 – shows through the window's frame and caption.

Value
The default is false: the window draws its frame from the skin.
Remarks

Takes effect only while desktop composition is on and the window is not right to left; CurrentlyRenderingGlassOnNCArea says whether it is in effect. A skin can decline Mica.

ScaleTransformScaleXAndScaleY

public double ScaleTransformScaleXAndScaleY

Gets or sets a zoom factor for the ribbon and the caption row, for a ribbon drawn larger or smaller than the rest of the window.

Value
1.0 (the default) is actual size; 1.25 is a quarter larger.
Remarks

Applied as a layout transform to the first BinaryRibbonBarPanel in the window, when the template is applied and on each change.

TitleBarMargin

public Thickness TitleBarMargin

Gets or sets the margin round the ribbon's title while a contextual tab set is on show.

Value
In logical pixels. The default is 4,0,4,0, and 4,4,4,0 while the window is maximised.

TitleBrush

public Brush TitleBrush

Gets the brush the ribbon's title is drawn with, set from the skin and the window's state.

WindowBorderEdgeRenderingMode

public RibbonWindowBorder.CornerStyle WindowBorderEdgeRenderingMode

Gets or sets which corners of the window are rounded.

Value
CornerStyle.Top (the default) rounds the top two, CornerStyle.All all four, and CornerStyle.Default none. A maximised window is always square.

WindowTitleBarBackgroundRenderingStyle

public WindowTitleBarBackgroundRenderingStyle WindowTitleBarBackgroundRenderingStyle

Gets or sets a title bar style that the built-in templates do not read.

Value
The default is Solid.
Remarks

Changing it has no visible effect; the caption's look comes from the skin.

Methods

ArrangeOverride

protected override Size ArrangeOverride(Size bounds)

Arranges the window's template across the whole window, caption included.

Parameters
bounds
The window's size.
Returns

The same size.

GetIsHitTestVisibleInChrome static

public static bool GetIsHitTestVisibleInChrome(DependencyObject element)

Gets whether an element in the caption takes clicks rather than letting the window be dragged.

Parameters
element
The element.
Returns

The setting; false unless set, or when element is null.

OnApplyTemplate

public override void OnApplyTemplate()

Takes the template's parts, sets up the ribbon display options button and applies ScaleTransformScaleXAndScaleY.

OnClosed

protected override void OnClosed(EventArgs e)

Stops following skin changes when the window closes.

Parameters
e
The data for the event.

OnContentChanged

protected override void OnContentChanged(object oldContent, object newContent)

Gives new content the window's direction when IsFlowDirectionRightToLeft is set.

Parameters
oldContent
The content replaced.
newContent
The new content.

OnDpiChanged

protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)

Fits the glass frame to the new display scale when the window moves to another monitor.

Parameters
oldDpi
The scale before the change.
newDpi
The scale after it.

OnSizeChanged

protected virtual void OnSizeChanged(object sender, SizeChangedEventArgs e)

Called when the window is resized; the base implementation reshapes the window's rounded outline and updates the title colour. Call it when overriding.

Parameters
sender
The window.
e
The old and new sizes.

OnSourceInitialized

protected override void OnSourceInitialized(EventArgs e)

Starts following skin changes and sets up the frame once the window has its handle.

Parameters
e
The data for the event.

OnStateChanged

protected override void OnStateChanged(EventArgs e)

Redraws the frame after the window is maximised or restored.

Parameters
e
The data for the event.

SetIsHitTestVisibleInChrome static

public static void SetIsHitTestVisibleInChrome(DependencyObject element, bool value)

Sets whether an element in the caption takes clicks rather than letting the window be dragged.

Parameters
element
The element. Ignored when null.
value
true for the element to take clicks.
Remarks

Buttons, text boxes, menus, selectors, thumbs and ribbon tabs take their clicks without it; set it on anything else in the caption – a picture, a panel – that should.

Example
<Image Source="Images/Account16.png" MouseLeftButtonUp="OnAccountClick"
       bm:BinaryRibbonWindow.IsHitTestVisibleInChrome="True" />

WndProc

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

Handles the window messages that let the window draw its own caption: frame size, hit testing, activation, text changes and desktop composition.

Parameters
hwnd
The window handle.
msg
The message.
wParam
The message's first parameter.
lParam
The message's second parameter.
resultFromExecution
Set to true when the message has been handled.
Returns

The message's result.

Fields

ApplicationMenuButtonRenderingStyleProperty static

public static readonly DependencyProperty ApplicationMenuButtonRenderingStyleProperty

Identifies the ApplicationMenuButtonRenderingStyle dependency property.

CurrentlyRenderingGlassOnNCAreaProperty static

public static DependencyProperty CurrentlyRenderingGlassOnNCAreaProperty

Identifies the CurrentlyRenderingGlassOnNCArea dependency property.

EnableDropShadowEffectOnWindowControlButtonsProperty static

public static readonly DependencyProperty EnableDropShadowEffectOnWindowControlButtonsProperty

Identifies the EnableDropShadowEffectOnWindowControlButtons dependency property.

GlassCaptionBrushProperty static

public static readonly DependencyProperty GlassCaptionBrushProperty

Identifies the GlassCaptionBrush dependency property.

IsFlowDirectionRightToLeftProperty static

public static readonly DependencyProperty IsFlowDirectionRightToLeftProperty

Identifies the IsFlowDirectionRightToLeft dependency property.

IsHitTestVisibleInChromeProperty static

public static readonly DependencyProperty IsHitTestVisibleInChromeProperty

Identifies the IsHitTestVisibleInChrome attached property.

IsWindowActiveAndCurrentProperty static

public static readonly DependencyProperty IsWindowActiveAndCurrentProperty

Identifies the IsRibbonWindowActiveAndCurrent dependency property.

IsWindowControlButtonsVisibleProperty static

public static readonly DependencyProperty IsWindowControlButtonsVisibleProperty

Identifies the IsWindowControlButtonsVisible dependency property.

QATPanelHeightProperty static

public static readonly DependencyProperty QATPanelHeightProperty

Identifies the QATPanelHeight dependency property.

QATPanelMarginProperty static

public static readonly DependencyProperty QATPanelMarginProperty

Identifies the QATPanelMargin dependency property.

RenderGlassIfOSSupportsProperty static

public static readonly DependencyProperty RenderGlassIfOSSupportsProperty

Identifies the RenderGlassIfOSSupports dependency property.

ScaleTransformScaleXAndScaleYProperty static

public static readonly DependencyProperty ScaleTransformScaleXAndScaleYProperty

Identifies the ScaleTransformScaleXAndScaleY dependency property.

TitleBarMarginProperty static

public static readonly DependencyProperty TitleBarMarginProperty

Identifies the TitleBarMargin dependency property.

TitleBrushProperty static

public static DependencyProperty TitleBrushProperty

Identifies the TitleBrush dependency property.

WindowBorderEdgeRenderingModeProperty static

public static readonly DependencyProperty WindowBorderEdgeRenderingModeProperty

Identifies the WindowBorderEdgeRenderingMode dependency property.

WindowTitleBarBackgroundRenderingStyleProperty static

public static readonly DependencyProperty WindowTitleBarBackgroundRenderingStyleProperty

Identifies the WindowTitleBarBackgroundRenderingStyle dependency property.