Class ContextMenu
A control context menu.
public class ContextMenu : MenuBase, INotifyPropertyChanged, IDataContextProvider, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IDataTemplateHost, IChildIndexProvider, IFocusScope, IInputElement, ILogical, ISetterValue, IPopupHostProvider
- Inheritance
-
ContextMenu
- Implements
- Inherited Members
- Extension Methods
Constructors
ContextMenu()
Initializes a new instance of the ContextMenu class.
public ContextMenu()
ContextMenu(IMenuInteractionHandler)
Initializes a new instance of the ContextMenu class.
public ContextMenu(IMenuInteractionHandler interactionHandler)
Parameters
interactionHandler
IMenuInteractionHandlerThe menu interaction handler.
Fields
CustomPopupPlacementCallbackProperty
Defines the CustomPopupPlacementCallback property.
public static readonly StyledProperty<CustomPopupPlacementCallback?> CustomPopupPlacementCallbackProperty
Field Value
HorizontalOffsetProperty
Defines the HorizontalOffset property.
public static readonly StyledProperty<double> HorizontalOffsetProperty
Field Value
PlacementAnchorProperty
Defines the PlacementAnchor property.
public static readonly StyledProperty<PopupAnchor> PlacementAnchorProperty
Field Value
PlacementConstraintAdjustmentProperty
Defines the PlacementConstraintAdjustment property.
public static readonly StyledProperty<PopupPositionerConstraintAdjustment> PlacementConstraintAdjustmentProperty
Field Value
PlacementGravityProperty
Defines the PlacementGravity property.
public static readonly StyledProperty<PopupGravity> PlacementGravityProperty
Field Value
PlacementProperty
Defines the Placement property.
public static readonly StyledProperty<PlacementMode> PlacementProperty
Field Value
PlacementRectProperty
Defines the PlacementRect property.
public static readonly StyledProperty<Rect?> PlacementRectProperty
Field Value
PlacementTargetProperty
Defines the PlacementTarget property.
public static readonly StyledProperty<Control?> PlacementTargetProperty
Field Value
VerticalOffsetProperty
Defines the VerticalOffset property.
public static readonly StyledProperty<double> VerticalOffsetProperty
Field Value
WindowManagerAddShadowHintProperty
Defines the WindowManagerAddShadowHint property.
public static readonly StyledProperty<bool> WindowManagerAddShadowHintProperty
Field Value
Properties
CustomPopupPlacementCallback
Gets or sets a delegate handler method that positions the Popup control, when Placement is set to Custom.
public CustomPopupPlacementCallback? CustomPopupPlacementCallback { get; set; }
Property Value
HorizontalOffset
Gets or sets the Horizontal offset of the popup in relation to the PlacementTarget.
public double HorizontalOffset { get; set; }
Property Value
Placement
Gets or sets the desired placement of the popup in relation to the PlacementTarget.
public PlacementMode Placement { get; set; }
Property Value
PlacementAnchor
Gets or sets the anchor point on the PlacementRect when Placement is AnchorAndGravity.
public PopupAnchor PlacementAnchor { get; set; }
Property Value
PlacementConstraintAdjustment
Gets or sets a value describing how the popup position will be adjusted if the unadjusted position would result in the popup being partly constrained.
public PopupPositionerConstraintAdjustment PlacementConstraintAdjustment { get; set; }
Property Value
PlacementGravity
Gets or sets a value which defines in what direction the popup should open when Placement is AnchorAndGravity.
public PopupGravity PlacementGravity { get; set; }
Property Value
PlacementRect
Gets or sets the anchor rectangle within the parent that the popup will be placed relative to when Placement is AnchorAndGravity.
public Rect? PlacementRect { get; set; }
Property Value
- Rect?
Remarks
The placement rect defines a rectangle relative to PlacementTarget around which the popup will be opened, with PlacementAnchor determining which edge of the placement target is used.
If unset, the anchor rectangle will be the bounds of the PlacementTarget.
PlacementTarget
Gets or sets the control that is used to determine the popup's position.
public Control? PlacementTarget { get; set; }
Property Value
VerticalOffset
Gets or sets the Vertical offset of the popup in relation to the PlacementTarget.
public double VerticalOffset { get; set; }
Property Value
WindowManagerAddShadowHint
public bool WindowManagerAddShadowHint { get; set; }
Property Value
Methods
Close()
Closes the menu.
public override void Close()
OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Called when a avalonia property changes on the object.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Parameters
change
AvaloniaPropertyChangedEventArgsThe property change details.
Open()
Opens the menu.
public override void Open()
Open(Control?)
Opens a context menu on the specified control.
public void Open(Control? control)
Parameters
control
ControlThe control.
Events
Closing
Occurs when the value of the Avalonia.Controls.ContextMenu.IsOpen property is changing from true to false.
public event CancelEventHandler? Closing
Event Type
Opening
Occurs when the value of the Avalonia.Controls.ContextMenu.IsOpen property is changing from false to true.
public event CancelEventHandler? Opening