private void ClosePickerPage() { // Unhook from events if (null != _frame) { _frame.Navigated -= new NavigatedEventHandler(HandleFrameNavigated); _frame.NavigationStopped -= new NavigationStoppedEventHandler(HandleFrameNavigationStoppedOrFailed); _frame.NavigationFailed -= new NavigationFailedEventHandler(HandleFrameNavigationStoppedOrFailed); // Restore host page transitions for the completed "popup" navigation UIElement frameContentWhenOpenedAsUIElement = _frameContentWhenOpened as UIElement; if (null != frameContentWhenOpenedAsUIElement) { TransitionService.SetNavigationInTransition(frameContentWhenOpenedAsUIElement, _savedNavigationInTransition); _savedNavigationInTransition = null; TransitionService.SetNavigationOutTransition(frameContentWhenOpenedAsUIElement, _savedNavigationOutTransition); _savedNavigationOutTransition = null; } _frame = null; _frameContentWhenOpened = null; } // Commit the value if available if (null != pickerPage) { if (pickerPage.Value.HasValue) { Value = pickerPage.Value.Value; } pickerPage = null; } }
private void HandleFrameNavigated(object sender, NavigationEventArgs e) { if (e.Content == _frameContentWhenOpened) { // Navigation to original page; close the picker page ClosePickerPage(); } else if (null == pickerPage) { // Navigation to a new page; capture it and push the value in pickerPage = e.Content as IDoublePickerPage; if (null != pickerPage) { pickerPage.Value = Value.GetValueOrDefault(0); } } }