Beispiel #1
0
        //TODO: .NET40
        public async void Close()
        {
            if (IsClosing)
            {
                return;
            }

            IsClosing = true;

            RaiseEvent(new RoutedEventArgs(NotificationCloseInvokedEvent));
            await Task.Delay(_closingAnimationTime);

            RaiseEvent(new RoutedEventArgs(NotificationClosedEvent));

            var currentWindow = Application.Current.Windows.OfType <Window>().FirstOrDefault(x => x.Title.Equals("ToastWindow"));

            if (currentWindow == null)
            {
                return;
            }
            var notificationCount = VisualTreeHelperExtensions.GetActiveNotificationCount(currentWindow);

            if (notificationCount == 0)
            {
                currentWindow?.Hide();
            }
        }