Skip to main content

Popup

The Popup is a low-level control that displays content in a floating window above other content. It serves as the foundation for higher-level controls like Flyout, ToolTip, ComboBox dropdowns, and context menus. Use Popup directly when you need custom positioning or dismissal behavior that those controls do not provide.

info

For most scenarios, prefer Flyout, ToolTip, or ContextMenu instead of Popup. These higher-level controls handle accessibility, keyboard navigation, and light-dismiss behavior automatically.

Useful properties

PropertyTypeDescription
IsOpenboolControls whether the popup is currently visible.
ChildControlThe content displayed inside the popup.
PlacementPlacementModeHow the popup is positioned relative to its target. Options include Bottom, Top, Left, Right, Center, Pointer, AnchorAndGravity. Default: Bottom.
PlacementTargetControlThe control the popup is positioned relative to. Defaults to the popup's parent.
PlacementAnchorPopupAnchorThe anchor point on the target control.
PlacementGravityPopupGravityThe direction the popup expands from the anchor point.
HorizontalOffsetdoubleHorizontal offset from the calculated position.
VerticalOffsetdoubleVertical offset from the calculated position.
IsLightDismissEnabledboolWhen true, the popup closes when the user clicks outside it. Default: false.
TopmostboolWhether the popup appears above all other windows. Default: false.
WindowManagerAddShadowHintboolWhether a drop shadow is applied (platform-dependent). Default: true.
OverlayDismissEventPassThroughboolWhen true, pointer events that dismiss the popup also pass through to the underlying control. Default: false.
CustomPopupPlacementCallbackAction<CustomPopupPlacement>A callback for fully custom popup positioning. When set, overrides the Placement property.

Events

EventDescription
OpenedRaised after the popup opens.
ClosedRaised after the popup closes.

Basic example

<Panel>
<Button x:Name="ToggleButton" Content="Show Popup"
Click="OnTogglePopup" />

<Popup x:Name="MyPopup"
PlacementTarget="{Binding #ToggleButton}"
Placement="Bottom"
IsLightDismissEnabled="True">
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
BorderBrush="{DynamicResource SystemControlForegroundBaseMediumBrush}"
BorderThickness="1" CornerRadius="4" Padding="12">
<TextBlock Text="This is popup content." />
</Border>
</Popup>
</Panel>
private void OnTogglePopup(object sender, RoutedEventArgs e)
{
MyPopup.IsOpen = !MyPopup.IsOpen;
}

Placement modes

The Placement property controls where the popup appears:

ModeBehavior
BottomBelow the target, left-aligned.
TopAbove the target, left-aligned.
LeftTo the left of the target, top-aligned.
RightTo the right of the target, top-aligned.
CenterCentered over the target.
PointerAt the current pointer position.
AnchorAndGravityUses PlacementAnchor and PlacementGravity for precise positioning.

Binding IsOpen

You can bind IsOpen to a view model property for MVVM control:

<Popup IsOpen="{Binding IsPopupVisible}"
PlacementTarget="{Binding #AnchorControl}"
Placement="Bottom"
IsLightDismissEnabled="True">
<Border Background="White" Padding="16" CornerRadius="4"
BoxShadow="0 2 8 0 #40000000">
<StackPanel Spacing="8">
<TextBlock Text="Choose an option:" FontWeight="SemiBold" />
<Button Content="Option A" Command="{Binding SelectOptionCommand}"
CommandParameter="A" />
<Button Content="Option B" Command="{Binding SelectOptionCommand}"
CommandParameter="B" />
</StackPanel>
</Border>
</Popup>

Custom placement

For positioning logic beyond the built-in placement modes, use CustomPopupPlacementCallback. The callback receives a CustomPopupPlacement object pre-initialized with defaults, and you modify its properties to control positioning:

myPopup.CustomPopupPlacementCallback = placement =>
{
placement.Anchor = PopupAnchor.TopRight;
placement.Gravity = PopupGravity.BottomRight;
placement.Offset = new Point(8, 0);
};

This callback is also available on PopupFlyoutBase, ContextMenu, and as an attached property on ToolTip:

ToolTip.SetCustomPopupPlacementCallback(myControl, placement =>
{
placement.Offset = new Point(0, -10);
});
FeaturePopupFlyoutToolTip
LevelLow-level primitiveHigh-level, attachedHigh-level, attached
TriggerManual (IsOpen)Programmatic or attachedHover
Light dismissOptionalBuilt-inBuilt-in
Keyboard supportManualAutomaticN/A
Best forCustom overlay behaviorMenus, confirmations, pickersHover hints

See also

  • Flyout: A higher-level popup attached to a control.
  • ToolTip: Hover-activated popups for supplementary text.
  • ContextMenu: Right-click menus.