Class MenuBase
Base class for menu controls.
public abstract class MenuBase : SelectingItemsControl, INotifyPropertyChanged, IDataContextProvider, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IDataTemplateHost, ISetterValue, IChildIndexProvider, IFocusScope, IInputElement, ILogical
- Inheritance
-
MenuBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
MenuBase()
Initializes a new instance of the MenuBase class.
protected MenuBase()
MenuBase(IMenuInteractionHandler)
Initializes a new instance of the MenuBase class.
protected MenuBase(IMenuInteractionHandler interactionHandler)
Parameters
interactionHandler
IMenuInteractionHandlerThe menu interaction handler.
Fields
ClosedEvent
Defines the Closed event.
public static readonly RoutedEvent<RoutedEventArgs> ClosedEvent
Field Value
IsOpenProperty
Defines the IsOpen property.
public static readonly DirectProperty<MenuBase, bool> IsOpenProperty
Field Value
OpenedEvent
Defines the Opened event.
public static readonly RoutedEvent<RoutedEventArgs> OpenedEvent
Field Value
Properties
InteractionHandler
Gets the interaction handler for the menu.
protected IMenuInteractionHandler InteractionHandler { get; }
Property Value
IsOpen
Gets a value indicating whether the menu is open.
public bool IsOpen { get; protected set; }
Property Value
Methods
Close()
Closes the menu.
public abstract void Close()
CreateContainerForItemOverride(object?, int, object?)
Creates or a container that can be used to display an item.
protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
Parameters
Returns
NeedsContainerOverride(object?, int, out object?)
Determines whether the specified item can be its own container.
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
Parameters
item
objectThe item to check.
index
intThe index of the item.
recycleKey
objectWhen the method returns, contains a key that can be used to locate a previously recycled container of the correct type, or null if the item cannot be recycled. If the item is its own container then by definition it cannot be recycled, so
recycleKey
shoud be set to null.
Returns
- bool
true if the item needs a container; otherwise false if the item can itself be used as a container.
OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
Called when the control is added to a rooted visual tree.
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe event args.
OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)
Called when the control is removed from a rooted visual tree.
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe event args.
OnKeyDown(KeyEventArgs)
Handles directional navigation within the ItemsControl.
protected override void OnKeyDown(KeyEventArgs e)
Parameters
e
KeyEventArgsThe key events.
OnSubmenuOpened(RoutedEventArgs)
Called when a submenu opens somewhere in the menu.
protected virtual void OnSubmenuOpened(RoutedEventArgs e)
Parameters
e
RoutedEventArgsThe event args.
Open()
Opens the menu.
public abstract void Open()
Events
Closed
Occurs when a Menu is closed.
public event EventHandler<RoutedEventArgs>? Closed
Event Type
Opened
Occurs when a Menu is opened.
public event EventHandler<RoutedEventArgs>? Opened