BinaryRibbonWindow
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 | |
|---|---|
BinaryRibbonWindow | Creates a ribbon window; give it a BinaryRibbonBarPanel as the first of its content. |
| Properties | |
ApplicationMenuButtonRenderingStyle | Gets or sets how the ribbon's application button is drawn. |
CloseWindow | Gets the command that closes the window, used by the caption's close button. |
CurrentlyRenderingGlassOnNCArea | Gets whether the operating system's glass is being drawn in the frame. |
EnableDropShadowEffectOnWindowControlButtons | Gets or sets whether a caption button casts a faint shadow while the pointer is over it. |
GlassCaptionBrush | Gets the fill the glass template paints its caption with where the operating system has no material of its own. |
IsFlowDirectionRightToLeft | Gets or sets whether the window is laid out right to left, for Arabic, Hebrew, Persian and the other right-to-left languages. |
IsRibbonWindowActiveAndCurrent | Gets whether the window is the active window, which its caption and frame colours follow. |
IsWindowControlButtonsVisible | Gets or sets whether the minimise, maximise and close buttons are shown in the caption. |
MaximizeWindow | Gets the command that maximises the window, or restores it when it is maximised. |
MinimizeWindow | Gets the command that minimises the window, used by the caption's minimise button. |
QATPanelHeight | Gets or sets the height of the quick access toolbar in the caption. |
QATPanelMargin | Gets or sets the margin round the quick access toolbar in the caption. |
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. |
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. |
TitleBarMargin | Gets or sets the margin round the ribbon's title while a contextual tab set is on show. |
TitleBrush | Gets the brush the ribbon's title is drawn with, set from the skin and the window's state. |
WindowBorderEdgeRenderingMode | Gets or sets which corners of the window are rounded. |
WindowTitleBarBackgroundRenderingStyle | Gets or sets a title bar style that the built-in templates do not read. |
| Methods | |
ArrangeOverride | Arranges the window's template across the whole window, caption included. |
GetIsHitTestVisibleInChrome | Gets whether an element in the caption takes clicks rather than letting the window be dragged. |
OnApplyTemplate | Takes the template's parts, sets up the ribbon display options button and applies ScaleTransformScaleXAndScaleY. |
OnClosed | Stops following skin changes when the window closes. |
OnContentChanged | Gives new content the window's direction when IsFlowDirectionRightToLeft is set. |
OnDpiChanged | Fits the glass frame to the new display scale when the window moves to another monitor. |
OnSizeChanged | Called when the window is resized; the base implementation reshapes the window's rounded outline and updates the title colour. Call it when overriding. |
OnSourceInitialized | Starts following skin changes and sets up the frame once the window has its handle. |
OnStateChanged | Redraws the frame after the window is maximised or restored. |
SetIsHitTestVisibleInChrome | Sets whether an element in the caption takes clicks rather than letting the window be dragged. |
WndProc | Handles the window messages that let the window draw its own caption: frame size, hit testing, activation, text changes and desktop composition. |
| Fields | |
ApplicationMenuButtonRenderingStyleProperty | Identifies the ApplicationMenuButtonRenderingStyle dependency property. |
CurrentlyRenderingGlassOnNCAreaProperty | Identifies the CurrentlyRenderingGlassOnNCArea dependency property. |
EnableDropShadowEffectOnWindowControlButtonsProperty | Identifies the EnableDropShadowEffectOnWindowControlButtons dependency property. |
GlassCaptionBrushProperty | Identifies the GlassCaptionBrush dependency property. |
IsFlowDirectionRightToLeftProperty | Identifies the IsFlowDirectionRightToLeft dependency property. |
IsHitTestVisibleInChromeProperty | Identifies the IsHitTestVisibleInChrome attached property. |
IsWindowActiveAndCurrentProperty | Identifies the IsRibbonWindowActiveAndCurrent dependency property. |
IsWindowControlButtonsVisibleProperty | Identifies the IsWindowControlButtonsVisible dependency property. |
QATPanelHeightProperty | Identifies the QATPanelHeight dependency property. |
QATPanelMarginProperty | Identifies the QATPanelMargin dependency property. |
RenderGlassIfOSSupportsProperty | Identifies the RenderGlassIfOSSupports dependency property. |
ScaleTransformScaleXAndScaleYProperty | Identifies the ScaleTransformScaleXAndScaleY dependency property. |
TitleBarMarginProperty | Identifies the TitleBarMargin dependency property. |
TitleBrushProperty | Identifies the TitleBrush dependency property. |
WindowBorderEdgeRenderingModeProperty | Identifies the WindowBorderEdgeRenderingMode dependency property. |
WindowTitleBarBackgroundRenderingStyleProperty | Identifies the WindowTitleBarBackgroundRenderingStyle dependency property. |
Constructors
BinaryRibbonWindow
Creates a ribbon window; give it a BinaryRibbonBarPanel as the first of its content.
Properties
CloseWindow static
Gets the command that closes the window, used by the caption's close button.
CurrentlyRenderingGlassOnNCArea
Gets whether the operating system's glass is being drawn in the frame.
- Value
truewhileRenderGlassIfOSSupportsis set and in effect.
EnableDropShadowEffectOnWindowControlButtons
Gets or sets whether a caption button casts a faint shadow while the pointer is over it.
- Value
- The default is
true.
GlassCaptionBrush
Gets the fill the glass template paints its caption with where the operating system has no material of its own.
- Value
nullwhile 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
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
Gets whether the window is the active window, which its caption and frame colours follow.
- Value
- The default is
falseuntil the window is first activated.
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
Gets the command that maximises the window, or restores it when it is maximised.
MinimizeWindow static
Gets the command that minimises the window, used by the caption's minimise button.
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
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
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
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
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
Gets the brush the ribbon's title is drawn with, set from the skin and the window's state.
WindowBorderEdgeRenderingMode
Gets or sets which corners of the window are rounded.
- Value
CornerStyle.Top(the default) rounds the top two,CornerStyle.Allall four, andCornerStyle.Defaultnone. A maximised window is always square.
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
Arranges the window's template across the whole window, caption included.
Parameters
bounds- The window's size.
Returns
The same size.
GetIsHitTestVisibleInChrome static
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
Takes the template's parts, sets up the ribbon display options button and applies ScaleTransformScaleXAndScaleY.
OnClosed
Stops following skin changes when the window closes.
Parameters
e- The data for the event.
OnContentChanged
Gives new content the window's direction when IsFlowDirectionRightToLeft is set.
Parameters
oldContent- The content replaced.
newContent- The new content.
OnDpiChanged
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
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
Starts following skin changes and sets up the frame once the window has its handle.
Parameters
e- The data for the event.
OnStateChanged
Redraws the frame after the window is maximised or restored.
Parameters
e- The data for the event.
SetIsHitTestVisibleInChrome static
Sets whether an element in the caption takes clicks rather than letting the window be dragged.
Parameters
element- The element. Ignored when
null. valuetruefor 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
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
truewhen the message has been handled.
Returns
The message's result.
Fields
CurrentlyRenderingGlassOnNCAreaProperty static
Identifies the CurrentlyRenderingGlassOnNCArea dependency property.
EnableDropShadowEffectOnWindowControlButtonsProperty static
Identifies the EnableDropShadowEffectOnWindowControlButtons dependency property.
GlassCaptionBrushProperty static
Identifies the GlassCaptionBrush dependency property.
IsFlowDirectionRightToLeftProperty static
Identifies the IsFlowDirectionRightToLeft dependency property.
IsHitTestVisibleInChromeProperty static
Identifies the IsHitTestVisibleInChrome attached property.
IsWindowActiveAndCurrentProperty static
Identifies the IsRibbonWindowActiveAndCurrent dependency property.
IsWindowControlButtonsVisibleProperty static
Identifies the IsWindowControlButtonsVisible dependency property.
QATPanelHeightProperty static
Identifies the QATPanelHeight dependency property.
QATPanelMarginProperty static
Identifies the QATPanelMargin dependency property.
RenderGlassIfOSSupportsProperty static
Identifies the RenderGlassIfOSSupports dependency property.
ScaleTransformScaleXAndScaleYProperty static
Identifies the ScaleTransformScaleXAndScaleY dependency property.
TitleBarMarginProperty static
Identifies the TitleBarMargin dependency property.
TitleBrushProperty static
Identifies the TitleBrush dependency property.
WindowBorderEdgeRenderingModeProperty static
Identifies the WindowBorderEdgeRenderingMode dependency property.
WindowTitleBarBackgroundRenderingStyleProperty static
Identifies the WindowTitleBarBackgroundRenderingStyle dependency property.