In This Article

BarPopupButtonBase Class

Represents an abstract base class for a popup button control that displays a menu.

[TemplatePart(Name = "PART_IndicatorArea", Type = typeof(FrameworkElement))]
[TemplatePart(Name = "PART_Popup", Type = typeof(Popup))]
[TemplatePart(Name = "PART_PopupContentHost", Type = typeof(ResizablePopupContentHost))]
public abstract class BarPopupButtonBase : Menu, IPopupAnchor
Inheritance:
object Visual UIElement FrameworkElement Control ItemsControl MenuBase Menu object
Derived:
BarPopupButton BarComboBoxDropDownButton DockableToolBarOptionsButton RibbonGalleryMoreButton RibbonGroupOverflowButton RibbonOptionsButton RibbonQuickAccessToolBarCustomizeButton RibbonTabItemOverflowButton RibbonApplicationButton
Implements:
IPopupAnchor

Constructors

BarPopupButtonBase()

Initializes an instance of the class.

protected BarPopupButtonBase()

Properties

CanEffectivelyExecute

Indicates whether the control can effectively execute the Command.

public bool CanEffectivelyExecute { get; protected set; }

Property Value

bool:

true if the control can effectively execute the Command; otherwise, false.

CanEffectivelyOpenPopup

Indicates whether the control can effectively open its popup.

public bool CanEffectivelyOpenPopup { get; protected set; }

Property Value

bool:

true if the control can effectively open its popup; otherwise, false.

CanFocusSelectedGalleryItemOnPopupOpen

Indicates whether the button can focus a selected gallery item when the popup is opened.

protected virtual bool CanFocusSelectedGalleryItemOnPopupOpen { get; }

Property Value

bool:

true if the button can focus a selected gallery item when the popup is opened; otherwise, false.

Command

The ICommand related to this button.

public ICommand? Command { get; set; }

Property Value

ICommand

CommandParameter

The parameter for the Command.

public object? CommandParameter { get; set; }

Property Value

object

CommandTarget

The IInputElement target for the Command.

public IInputElement? CommandTarget { get; set; }

Property Value

IInputElement

CornerRadius

The corner radius of the control's border.

public CornerRadius CornerRadius { get; set; }

Property Value

CornerRadius

HasDropShadow

Indicates whether the popup has a drop shadow.

public bool HasDropShadow { get; set; }

Property Value

bool:

true if the popup has a drop shadow; otherwise, false. The default value is true.

HasLabel

Indicates whether the control has a Label available.

public bool HasLabel { get; }

Property Value

bool:

true if the control has a Label available; otherwise, false. The default value is false.

IsEnabledCore

Gets a value that becomes the return value of IsEnabled in derived classes.

protected override bool IsEnabledCore { get; }

Property Value

bool:

true if the element is enabled; otherwise, false.

IsPopupOpen

Indicates whether the popup is currently open.

public bool IsPopupOpen { get; set; }

Property Value

bool:

true if the popup is currently open; otherwise, false. The default value is false.

IsPressed

Indicates whether the control is currently pressed.

public bool IsPressed { get; protected set; }

Property Value

bool:

true if the control is currently pressed; otherwise, false. The default value is false.

KeyTipText

The key tip text used to access the control.

[Localizability(LocalizationCategory.Label)]
public string? KeyTipText { get; set; }

Property Value

string

Label

The text label to display.

[Localizability(LocalizationCategory.Label)]
public string? Label { get; set; }

Property Value

string

ParentGalleryMinWidth

The parent gallery's minimum width.

public double ParentGalleryMinWidth { get; protected set; }

Property Value

double

PopupAnimation

The PopupAnimation to use in the popup.

public PopupAnimation PopupAnimation { get; set; }

Property Value

PopupAnimation

PopupBackground

The Brush for the popup's background.

public Brush? PopupBackground { get; set; }

Property Value

Brush

PopupBorderBrush

The Brush for the popup's border.

public Brush? PopupBorderBrush { get; set; }

Property Value

Brush

PopupBorderThickness

The Thickness of the popup's border.

public Thickness PopupBorderThickness { get; set; }

Property Value

Thickness

PopupClosedCommand

The ICommand that executes after the button's popup is closed, allowing its items to be customized in MVVM scenarios.

public ICommand? PopupClosedCommand { get; set; }

Property Value

ICommand

PopupCornerRadius

The CornerRadius of the popup's border.

public CornerRadius PopupCornerRadius { get; set; }

Property Value

CornerRadius

PopupHorizontalOffset

The horizontal offset of the popup.

public double PopupHorizontalOffset { get; set; }

Property Value

double

PopupIndicatorTemplate

The DataTemplate for the popup indicator.

public DataTemplate? PopupIndicatorTemplate { get; set; }

Property Value

DataTemplate

PopupOpeningCommand

The ICommand that executes before the button's popup is opened, allowing its items to be customized in MVVM scenarios.

public ICommand? PopupOpeningCommand { get; set; }

Property Value

ICommand

PopupPadding

The Thickness of the popup's padding.

public Thickness PopupPadding { get; set; }

Property Value

Thickness

PopupVerticalOffset

The vertical offset of the popup.

public double PopupVerticalOffset { get; set; }

Property Value

double

Methods

ClearContainerForItemOverride(DependencyObject, object)

When overridden in a derived class, undoes the effects of the PrepareContainerForItemOverride(DependencyObject, object) method.

protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

The container element.

item object

The item.

ExecuteClickFromKeyboard()

Executes a click event generated by a keyboard action.

protected virtual void ExecuteClickFromKeyboard()

GetContainerForItemOverride()

Creates or identifies the element used to display the specified item.

protected override DependencyObject GetContainerForItemOverride()

Returns

DependencyObject:

The element used to display the specified item.

HandleMouseButton(MouseButtonEventArgs)

Called when any mouse button is pressed or released.

protected override void HandleMouseButton(MouseButtonEventArgs e)
Parameter Type Description
e MouseButtonEventArgs

A MouseButtonEventArgs that contains the event data.

IsItemItsOwnContainerOverride(object)

Determines whether the specified item is, or is eligible to be, its own item container.

protected override bool IsItemItsOwnContainerOverride(object item)
Parameter Type Description
item object

The item to check whether it is an item container.

Returns

bool:

true if the item is a MenuItem or a Separator; otherwise, false.

IsOverButtonArea(MouseEventArgs)

Returns whether the pointer is over the control's button area.

protected bool IsOverButtonArea(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The MouseEventArgs to examine.

Returns

bool:

true if the pointer is over the control's button area; otherwise, false.

OnApplyTemplate()

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

public override void OnApplyTemplate()

OnClick(RoutedEventArgs)

Occurs when the button is clicked in an area outside of the popup indicator area.

protected virtual void OnClick(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The RoutedEventArgs containing data related to this event.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnIndicatorAreaMouseDown(MouseButtonEventArgs)

Occurs when a pointer button is pressed over the indicator area.

protected virtual void OnIndicatorAreaMouseDown(MouseButtonEventArgs e)
Parameter Type Description
e MouseButtonEventArgs

The MouseButtonEventArgs containing data related to this event.

OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs)

Responds to a change to the IsKeyboardFocusWithin property.

protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data for the IsKeyboardFocusWithinChanged event.

OnKeyDown(KeyEventArgs)

Responds to the KeyDown event.

protected override void OnKeyDown(KeyEventArgs e)
Parameter Type Description
e KeyEventArgs

A KeyEventArgs that contains the event data.

OnKeyTipInvoked(KeyTipInvokedEventArgs)

Occurs when the control's key tip is invoked.

protected virtual void OnKeyTipInvoked(KeyTipInvokedEventArgs e)
Parameter Type Description
e KeyTipInvokedEventArgs

The KeyTipInvokedEventArgs containing data related to this event.

OnKeyTipOpening(KeyTipOpeningEventArgs)

Occurs when the control's key tip is opening.

protected virtual void OnKeyTipOpening(KeyTipOpeningEventArgs e)
Parameter Type Description
e KeyTipOpeningEventArgs

The KeyTipOpeningEventArgs containing data related to this event.

OnPopupClosed(RoutedEventArgs)

Occurs when the IsPopupOpen property changes to false.

protected virtual void OnPopupClosed(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnPopupOpened(RoutedEventArgs)

Occurs when the IsPopupOpen property changes to true.

protected virtual void OnPopupOpened(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnPopupOpening(CancelRoutedEventArgs)

Occurs before the IsPopupOpen property changes to true.

protected virtual void OnPopupOpening(CancelRoutedEventArgs e)
Parameter Type Description
e CancelRoutedEventArgs

The event data.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnPreviewKeyUp(KeyEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.PreviewKeyUp attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnPreviewKeyUp(KeyEventArgs e)
Parameter Type Description
e KeyEventArgs

The KeyEventArgs that contains the event data.

PrepareContainerForItemOverride(DependencyObject, object)

Prepares the specified element to display the specified item.

protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

The element used to display the specified item.

item object

The item to display.

SetFocusForIndicatorAreaMouseDown()

Sets focus in response to an indicator area mouse down.

protected virtual bool SetFocusForIndicatorAreaMouseDown()

Returns

bool:

true if focus was set; otherwise, false.

UpdateEnabledProperties()

Updates the CanEffectivelyExecute and CanEffectivelyOpenPopup properties.

protected virtual void UpdateEnabledProperties()

UpdatePopupPlacement()

Updates the popup placement as needed.

protected virtual void UpdatePopupPlacement()

Events

PopupClosed

Occurs when the IsPopupOpen property changes to false.

public event RoutedEventHandler PopupClosed

Event Type

RoutedEventHandler

PopupOpened

Occurs when the IsPopupOpen property changes to true.

public event RoutedEventHandler PopupOpened

Event Type

RoutedEventHandler

PopupOpening

Occurs before the IsPopupOpen property changes to true.

public event EventHandler<CancelRoutedEventArgs> PopupOpening

Event Type

EventHandler<CancelRoutedEventArgs>

Fields

CanEffectivelyExecuteProperty

Defines the CanEffectivelyExecute property.

public static readonly DependencyProperty CanEffectivelyExecuteProperty

CanEffectivelyOpenPopupProperty

Defines the CanEffectivelyOpenPopup property.

public static readonly DependencyProperty CanEffectivelyOpenPopupProperty

CommandParameterProperty

Defines the CommandParameter property.

public static readonly DependencyProperty CommandParameterProperty

CommandProperty

Defines the Command property.

public static readonly DependencyProperty CommandProperty

CommandTargetProperty

Defines the CommandTarget property.

public static readonly DependencyProperty CommandTargetProperty

CornerRadiusProperty

Defines the CornerRadius property.

public static readonly DependencyProperty CornerRadiusProperty

HasDropShadowProperty

Defines the HasDropShadow property.

public static readonly DependencyProperty HasDropShadowProperty

HasLabelProperty

Defines the HasLabel property.

public static readonly DependencyProperty HasLabelProperty

IsPopupOpenProperty

Defines the IsPopupOpen property.

public static readonly DependencyProperty IsPopupOpenProperty

IsPressedProperty

Defines the IsPressed property.

public static readonly DependencyProperty IsPressedProperty

KeyTipTextProperty

Defines the KeyTipText property.

public static readonly DependencyProperty KeyTipTextProperty

LabelProperty

Defines the Label property.

public static readonly DependencyProperty LabelProperty

ParentGalleryMinWidthProperty

Defines the ParentGalleryMinWidth property.

public static readonly DependencyProperty ParentGalleryMinWidthProperty

PopupAnimationProperty

Defines the PopupAnimation property.

public static readonly DependencyProperty PopupAnimationProperty

PopupBackgroundProperty

Defines the PopupBackground property.

public static readonly DependencyProperty PopupBackgroundProperty

PopupBorderBrushProperty

Defines the PopupBorderBrush property.

public static readonly DependencyProperty PopupBorderBrushProperty

PopupBorderThicknessProperty

Defines the PopupBorderThickness property.

public static readonly DependencyProperty PopupBorderThicknessProperty

PopupClosedCommandProperty

Defines the PopupClosedCommand property.

public static readonly DependencyProperty PopupClosedCommandProperty

PopupClosedEvent

Defines the PopupClosed routed event.

public static readonly RoutedEvent PopupClosedEvent

PopupCornerRadiusProperty

Defines the PopupCornerRadius property.

public static readonly DependencyProperty PopupCornerRadiusProperty

PopupHorizontalOffsetProperty

Defines the PopupHorizontalOffset property.

public static readonly DependencyProperty PopupHorizontalOffsetProperty

PopupIndicatorTemplateProperty

Defines the PopupIndicatorTemplate property.

public static readonly DependencyProperty PopupIndicatorTemplateProperty

PopupOpenedEvent

Defines the PopupOpened routed event.

public static readonly RoutedEvent PopupOpenedEvent

PopupOpeningCommandProperty

Defines the PopupOpeningCommand property.

public static readonly DependencyProperty PopupOpeningCommandProperty

PopupOpeningEvent

Defines the PopupOpening routed event.

public static readonly RoutedEvent PopupOpeningEvent

PopupPaddingProperty

Defines the PopupPadding property.

public static readonly DependencyProperty PopupPaddingProperty

PopupVerticalOffsetProperty

Defines the PopupVerticalOffset property.

public static readonly DependencyProperty PopupVerticalOffsetProperty

Extension Methods