FlyoutBase.ShouldConstrainToRootBounds FlyoutBase.ShouldConstrainToRootBounds FlyoutBase.ShouldConstrainToRootBounds FlyoutBase.ShouldConstrainToRootBounds Property

Definition

Gets or sets a value that indicates whether the flyout should be shown within the bounds of the XAML root.

public : Platform::Boolean ShouldConstrainToRootBounds { get; set; }
bool ShouldConstrainToRootBounds();

void ShouldConstrainToRootBounds(bool shouldconstraintorootbounds);
public bool ShouldConstrainToRootBounds { get; set; }
Public ReadWrite Property ShouldConstrainToRootBounds As bool

Property Value

bool bool

true if the flyout should be shown within the bounds of the XAML root; otherwise, false. The default is false.

Additional features and requirements

Device family
Windows 10, version 1903 (introduced v10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v8)

Examples

In this example, the flyout is not restricted to the root bounds by default. Therefore, the request to place the flyout below the button is honored as long as there is room for it on the display. The flyout is shown outside of the app window.

<Button Content="Button"
        VerticalAlignment="Bottom" HorizontalAlignment="Center">
    <Button.Flyout>
        <Flyout Placement="Bottom">
            <TextBlock Text="Flyout content" />
        </Flyout>
    </Button.Flyout>
</Button>
A closed app bar control

In this example, ShouldConstrainToRootBounds is set to true, so the flyout is restricted to the root bounds. Therefore, the request to place the flyout below the button is not honored, and the flyout is shown inside the app window above the button.

<Button Content="Button"
        VerticalAlignment="Bottom" HorizontalAlignment="Center">
    <Button.Flyout>
        <Flyout Placement="Bottom"
                ShouldConstrainToRootBounds="True">
            <TextBlock Text="Flyout content" />
        </Flyout>
    </Button.Flyout>
</Button>
A closed app bar control

Remarks

This property is applicable only to apps running on the desktop. On other platforms, it does not have an effect. To check if the flyout is actually constrained to the root bounds, check the IsConstrainedToRootBounds property.

In a UWP app on desktop, when this property is true, the flyout is shown within the main XAML window handle (HWND). When this property is false, the flyout is shown in its own top level HWND. In this case, the flyout might be positioned to extend beyond the main app window.

When a flyout with ShouldConstrainToRootBounds = false is first shown, it’s placed in its own window and shown in that context. After it has been shown, ShouldConstrainToRootBounds cannot be set back to true.

The XAML root might be a CoreWindow, a XAML island, or an AppWindow.

See also