MahApps.Metro icon indicating copy to clipboard operation
MahApps.Metro copied to clipboard

New "Auto Close" feature for flyouts

Open mgnslndh opened this issue 11 years ago • 2 comments

It would be nice to be able to set a TimeSpan on a Flyout that would make it auto close after that amount of time. With this feature flyouts could be used for notifications more easily.

mgnslndh avatar Dec 18 '14 10:12 mgnslndh

If you're using the Flyout for notifications, you're probably using a method that sets the notification message and opens the Flyout.

I've been using this method in another (private) project for displaying a status to the user; you might find it helpful. Status is the Flyout that is being used as a notification. I call this every time I want to display a notification.

using System.Windows.Media.Animation;
public void ShowStatus(string status, double duration = 2.5)
{
    Status.Header = status;
    BooleanAnimationUsingKeyFrames statusAnimation = new BooleanAnimationUsingKeyFrames();
    statusAnimation.KeyFrames.Add(new DiscreteBooleanKeyFrame() { KeyTime = TimeSpan.FromSeconds(0), Value = true });
    statusAnimation.KeyFrames.Add(new DiscreteBooleanKeyFrame() { KeyTime = TimeSpan.FromSeconds(duration + 0.5), Value = false }); //That 0.5 is for the Show animation
    Status.BeginAnimation(MahApps.Metro.Controls.Flyout.IsOpenProperty, statusAnimation);
}

Dotnetifier avatar Dec 23 '14 20:12 Dotnetifier

added with https://github.com/MahApps/MahApps.Metro/commit/8a77e75e0f095a46dfc8ae90430b7bfbe8311c45

punker76 avatar Jan 27 '16 22:01 punker76