Class Popup
- Namespace
- Avalonia.Controls.Primitives
- Assembly
- Avalonia.Controls.dll
Displays a popup window.
public class Popup : Control, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IPopupHostProvider
- Inheritance
-
Popup
- Implements
- Inherited Members
- Extension Methods
Constructors
Popup()
public Popup()
Fields
ChildProperty
Defines the Child property.
public static readonly StyledProperty<Control?> ChildProperty
Field Value
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
InheritsTransformProperty
Defines the InheritsTransform property.
public static readonly StyledProperty<bool> InheritsTransformProperty
Field Value
IsLightDismissEnabledProperty
Defines the IsLightDismissEnabled property.
public static readonly StyledProperty<bool> IsLightDismissEnabledProperty
Field Value
IsOpenProperty
Defines the IsOpen property.
public static readonly StyledProperty<bool> IsOpenProperty
Field Value
IsUsingOverlayLayerProperty
Defines the IsUsingOverlayLayer property.
public static readonly DirectProperty<Popup, bool> IsUsingOverlayLayerProperty
Field Value
OverlayDismissEventPassThroughProperty
Defines the OverlayDismissEventPassThrough property.
public static readonly StyledProperty<bool> OverlayDismissEventPassThroughProperty
Field Value
OverlayInputPassThroughElementProperty
Defines the OverlayInputPassThroughElement property.
public static readonly StyledProperty<IInputElement?> OverlayInputPassThroughElementProperty
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
ShouldUseOverlayLayerProperty
Defines the ShouldUseOverlayLayer property.
public static readonly StyledProperty<bool> ShouldUseOverlayLayerProperty
Field Value
TakesFocusFromNativeControlProperty
Defines the TakesFocusFromNativeControl property.
public static readonly AttachedProperty<bool> TakesFocusFromNativeControlProperty
Field Value
TopmostProperty
Defines the Topmost property.
public static readonly StyledProperty<bool> TopmostProperty
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
Child
Gets or sets the control to display in the popup.
[Content]
public Control? Child { get; set; }
Property Value
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
DependencyResolver
Gets or sets a dependency resolver for the PopupRoot.
public IAvaloniaDependencyResolver? DependencyResolver { get; set; }
Property Value
Remarks
This property allows a client to customize the behaviour of the popup by injecting a specialized dependency resolver into the PopupRoot's constructor.
HorizontalOffset
Gets or sets the Horizontal offset of the popup in relation to the PlacementTarget.
public double HorizontalOffset { get; set; }
Property Value
Host
public IPopupHost? Host { get; }
Property Value
InheritsTransform
Gets or sets a value that determines whether the popup inherits the render transform from its PlacementTarget. Defaults to false.
public bool InheritsTransform { get; set; }
Property Value
IsLightDismissEnabled
Gets or sets a value that determines how the Popup can be dismissed.
public bool IsLightDismissEnabled { get; set; }
Property Value
Remarks
Light dismiss is when the user taps on any area other than the popup.
IsOpen
Gets or sets a value indicating whether the popup is currently open.
public bool IsOpen { get; set; }
Property Value
IsPointerOverPopup
public bool IsPointerOverPopup { get; }
Property Value
IsUsingOverlayLayer
Gets a value that indicates whether the popup is shown in the overlay layer of the parent window.
public bool IsUsingOverlayLayer { get; }
Property Value
OverlayDismissEventPassThrough
Gets or sets a value indicating whether the event that closes the popup is passed through to the parent window.
public bool OverlayDismissEventPassThrough { get; set; }
Property Value
Remarks
When IsLightDismissEnabled is set to true, clicks outside the popup cause the popup to close. When OverlayDismissEventPassThrough is set to false, these clicks will be handled by the popup and not be registered by the parent window. When set to true, the events will be passed through to the parent window.
OverlayInputPassThroughElement
Gets or sets an element that should receive pointer input events even when underneath the popup's overlay.
public IInputElement? OverlayInputPassThroughElement { 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.
[ResolveByName]
public Control? PlacementTarget { get; set; }
Property Value
ShouldUseOverlayLayer
Gets or sets a value that indicates whether the popup should be shown in the overlay layer of the parent window.
public bool ShouldUseOverlayLayer { get; set; }
Property Value
Remarks
When ShouldUseOverlayLayer is "false" implementation depends on the platform.
Use IsUsingOverlayLayer to get actual popup behavior.
This is an equvalent of OverlayPopups
property of the platform options, but settable independently per each popup.
TakesFocusFromNativeControl
Gets or sets a value indicating whether the popup, on show, transfers focus from any
focused native control to Avalonia. The default is true
.
public bool TakesFocusFromNativeControl { get; set; }
Property Value
Remarks
This property only applies to advanced native control embedding scenarios. By default,
if a popup is shown when a native control is focused, focus is transferred back to
Avalonia in order for the popup to receive input. If this property is set to
false
, then the shown popup will not receive input until it receives an
interaction which explicitly focuses the popup, such as a mouse click.
Topmost
Gets or sets whether this popup appears on top of all other windows
public bool Topmost { 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
Gets or sets a hint to the window manager that a shadow should be added to the popup.
public bool WindowManagerAddShadowHint { get; set; }
Property Value
Methods
Close()
Closes the popup.
public void Close()
GetTakesFocusFromNativeControl(Control)
Gets the value of the TakesFocusFromNativeControl attached property on the specified control.
public static bool GetTakesFocusFromNativeControl(Control control)
Parameters
control
ControlThe control.
Returns
IsInsidePopup(Visual)
public bool IsInsidePopup(Visual visual)
Parameters
visual
Visual
Returns
MeasureCore(Size)
Measures the control.
protected override Size MeasureCore(Size availableSize)
Parameters
availableSize
SizeThe available size for the control.
Returns
- Size
A size of 0,0 as Popup itself takes up no space.
OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
Called when the control is added to a rooted visual tree.
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe event args.
OnCreateAutomationPeer()
Returns a new, type-specific AutomationPeer implementation for the control.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer
The type-specific AutomationPeer implementation.
OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs)
Called when the styled element is removed from a rooted logical tree.
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
Parameters
e
LogicalTreeAttachmentEventArgsThe event args.
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 popup.
public void Open()
SetTakesFocusFromNativeControl(Control, bool)
Sets the value of the TakesFocusFromNativeControl attached property on the specified control.
public static void SetTakesFocusFromNativeControl(Control control, bool value)
Parameters
Events
Closed
Raised when the popup closes.
public event EventHandler<EventArgs>? Closed
Event Type
Opened
Raised when the popup opens.
public event EventHandler? Opened