Search code examples
uwpuwp-xamlsubmenuboundsflyout

Restrict flyout to current AppWindow's boundary


I want to restrict a flyout and its submbmenu flyouts to the window of the app. This is what it looks like right now:

ShouldConstrainToRootBounds is false But when I try to set ShouldConstrainToRootBounds to true the submenuflyout displays really small number of items:

ShouldConstrainToRootBounds is true

How do I make my submenuflyouts display maximum number of contents while still restricting it to app's window.


Solution

  • This is a new feature in 1903 and above systems, that is, controls inherited from FlyoutBase are not constrained by app window.

    I reproduced your problem, which only appears if the currently displayed sub-item is greater than the height of the current window. The specific display position is calculated internally by MenuFlyout, and because Flyout and Window are not at the same level, the current solution is to set ShouldConstrainToRootBounds to False, so that MenuFlyout can be completely displayed.