void radioListGropus_GroupViewClosing(object sender, GroupViewClosingEventArgs e) { e.Cancel = true; SwivelTransition transition = new SwivelTransition(); ItemContainerGenerator itemContainerGenerator = e.ItemsControl.ItemContainerGenerator; int animationFinished = 0; int itemCount = e.ItemsControl.Items.Count; for (int i = 0; i < itemCount; i++) { UIElement element = itemContainerGenerator.ContainerFromIndex(i) as UIElement; ITransition animation = transition.GetTransition(element); animation.Completed += delegate { // close the group view when all animations have completed if ((++animationFinished) == itemCount) { radioListGropus.CloseGroupView(); radioListGropus.ScrollToGroup(e.SelectedGroup); } }; animation.Begin(); } }
/// <summary> /// Called when the visual layout changes. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event information.</param> private void CustomMessageBox_LayoutUpdated(object sender, EventArgs e) { SwivelTransition backwardIn = new SwivelTransition { Mode = SwivelTransitionMode.BackwardIn }; ITransition swivelTransition = backwardIn.GetTransition(this); swivelTransition.Completed += (s1, e1) => swivelTransition.Stop(); swivelTransition.Begin(); LayoutUpdated -= CustomMessageBox_LayoutUpdated; }
/// <summary> /// Dismisses the message box. /// </summary> /// <param name="source"> /// The source that caused the dismission. /// </param> /// <param name="useTransition"> /// If true, the message box is dismissed after swiveling /// backward and out. /// </param> private void Dismiss(CustomMessageBoxResult source, bool useTransition) { // Ensure only a single Dismiss is being handled at a time if (_isBeingDismissed) { return; } _isBeingDismissed = true; // Handle the dismissing event. var handlerDismissing = Dismissing; if (handlerDismissing != null) { DismissingEventArgs args = new DismissingEventArgs(source); handlerDismissing(this, args); if (args.Cancel) { _isBeingDismissed = false; return; } } // Set the current instance to null. _currentInstance = null; // Cache this variable to avoid a race condition. bool restoreOriginalValues = _mustRestore; // Close popup. if (useTransition) { SwivelTransition backwardOut = new SwivelTransition { Mode = SwivelTransitionMode.BackwardOut }; ITransition swivelTransition = backwardOut.GetTransition(this); swivelTransition.Completed += (s, e) => { swivelTransition.Stop(); ClosePopup(restoreOriginalValues, source); }; swivelTransition.Begin(); } else { ClosePopup(restoreOriginalValues, source); } _isBeingDismissed = false; }
/// <summary> /// Dismisses the message box. /// </summary> /// <param name="source"> /// The source that caused the dismission. /// </param> /// <param name="useTransition"> /// If true, the message box is dismissed after swiveling /// backward and out. /// </param> private void Dismiss(CustomMessageBoxResult source, bool useTransition) { // Handle the dismissing event. var handlerDismissing = Dismissing; if (handlerDismissing != null) { DismissingEventArgs args = new DismissingEventArgs(source); handlerDismissing(this, args); if (args.Cancel) { return; } } // Handle the dismissed event. var handlerDismissed = Dismissed; if (handlerDismissed != null) { DismissedEventArgs args = new DismissedEventArgs(source); handlerDismissed(this, args); } // Set the current instance to null. _currentInstance = null; // Cache this variable to avoid a race condition. bool restoreOriginalValues = _mustRestore; // Close popup. if (useTransition) { SwivelTransition backwardOut = new SwivelTransition { Mode = SwivelTransitionMode.BackwardOut }; ITransition swivelTransition = backwardOut.GetTransition(this); swivelTransition.Completed += (s, e) => { swivelTransition.Stop(); ClosePopup(restoreOriginalValues); }; Deployment.Current.Dispatcher.BeginInvoke(swivelTransition.Begin); } else { ClosePopup(restoreOriginalValues); } }