Wiktor Kęska
Wiktor Kęska

Reputation: 561

Detect if Shell Flyout is open

Is there any way to handle opening Flyout? I'm trying to add custom behavior during opening or after opening Flyout.

I can;t find any type of propety like Shell.OnFlyoutOpening="flyout_opening"

Upvotes: 4

Views: 659

Answers (1)

Cfun
Cfun

Reputation: 9721

Since there is no and won't be events such OnFlyoutOpened OnFlyoutClosed, you can listen to your Shell PropertyChanged event, if the property is FlyoutIsPresented then execute your code:

public AppShell()
{
    InitializeComponent();
    PropertyChanged += Shell_PropertyChanged;
}

private void Shell_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (e.PropertyName.Equals("FlyoutIsPresented"))
        if (FlyoutIsPresented)
            OnFlyoutOpened();
        else
            OnFlyoutClosed();
}

Depending on your requirement you will define OnFlyoutOpened() and OnFlyoutClosed() methods.

Thanks to @PureWeen guidance in discussion.

Upvotes: 6

Related Questions