Flyout
Flyouts are dismissible containers that can be attached to some classes of 'host' control; although flyouts themselves are not controls. They show when their host control receives the focus, and are hidden again in a number of different ways.
A flyout can contain simple or richer, composed, UI content.
Flyouts can be declared as a resource and shared between two or more host controls in an Avalonia UI app.
Examples
A flyout is attached to a host control using the host's Flyout
property. For example:
<Button Content="Button with Flyout">
<Button.Flyout >
<Flyout>This is the button flyout.</Flyout>
</Button.Flyout>
</Button>
Only the button and split button controls support the Flyout
property. You can attach a flyout to other Avalonia UI built-in controls using the AttachedFlyout
property instead.
For controls that do not have the Flyout
property, use the AttachedFlyout
property like this:
<Border Background="Red" PointerPressed="Border_PointerPressed">
<FlyoutBase.AttachedFlyout>
<Flyout>
<TextBlock Text="Red Rectangle Flyout." />
</Flyout>
</FlyoutBase.AttachedFlyout>
</Border>
The flyout will not show automatically, it has to be shown from code-behind. For example:
public void Border_PointerPressed(object sender, PointerPressedEventArgs args)
{
var ctl = sender as Control;
if (ctl != null)
{
FlyoutBase.ShowAttachedFlyout(ctl);
}
}