private void OnPopupClosedStateChanged(object sender, VisualStateChangedEventArgs e) { // Delayed closing of the popup until now if(e != null && e.NewState != null && e.NewState.Name == VisualStates.StatePopupClosed) { if(Popup != null) { Popup.IsOpen = false; } OnClosed(EventArgs.Empty); } }