private void NotifyArrival_Click(object sender, RoutedEventArgs e) { ArrivalAndDeparture a = (ArrivalAndDeparture)(((FrameworkElement)sender).DataContext); this.popup = new Popup(); NotifyPopup notifyPopup = new NotifyPopup(); notifyPopup.Notify_Completed += delegate(object o, NotifyEventArgs args) { if (args.okSelected == true) { this.viewModel.SubscribeToToastNotification(a.stopId, a.tripId, args.minutes); } // This is how we track if the popup is visible Dispatcher.BeginInvoke(() => { this.popup.IsOpen = false; }); }; this.popup.Child = notifyPopup; this.popup.IsOpen = true; }