UWP/WinUI 2 - How to increase the maximum size of a Flyout
The Flyout is a useful class in UWP/WinUI 2 that allows you to display content in a popup. The Flyout class contains various useful built in behaviour such as showing and hiding animations and functionality to for dismissing the popup when it looses focus. One of the built in behaviours of the Flyout, is that it contains a ScrollViewer and a maximum size. This means that, if the content inside the Flyout becomes too large for the Flyout, the content will become scrollable. In some situations, this behaviour can be helpful, however, in other situations, you may want the flyout to simply size itself to fit its content rather than cutting content off and forcing the user to scroll to see the cut off content. Luckily, there's an easy way to do this by modifying a Flyout's FlyoutPresenterStyle.
How to change the maximum size of a Flyout
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter" BasedOn="{StaticResource DefaultFlyoutPresenterStyle}">
<Setter Property="MaxHeight" Value="Infinity"/>
<Setter Property="MaxWidth" Value="Infinity"/>
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled"/>
</Style>
</Flyout.FlyoutPresenterStyle>
Comments
Post a Comment