private void OnListPickerModeChanged(ListPickerMode oldValue, ListPickerMode newValue) { // Hook up to frame if not already done if (null == _frame) { _frame = Application.Current.RootVisual as PhoneApplicationFrame; if (null != _frame) { _frame.AddHandler(ManipulationCompletedEvent, new EventHandler <ManipulationCompletedEventArgs>(HandleFrameManipulationCompleted), true); } } // Restore state if ((ListPickerMode.Full == oldValue) && !DesignerProperties.IsInDesignTool) { if (null != _fullModePopupPart) { _fullModePopupPart.IsOpen = false; } if (null != _fullModeSelectorPart) { _fullModeSelectorPart.SelectionChanged -= HandleFullModeSelectorPartSelectionChanged; _fullModeSelectorPart.Loaded -= HandleFullModeSelectorPartLoaded; _fullModeSelectorPart.ItemsSource = null; } Action restoreSystemTray = () => { try { SystemTray.IsVisible = _savedSystemTrayIsVisible; } catch (InvalidOperationException) { } }; try { restoreSystemTray(); } catch (InvalidOperationException) { Dispatcher.BeginInvoke(restoreSystemTray); } if (null != _page) { if (null != _page.ApplicationBar) { _page.ApplicationBar.IsVisible = _savedApplicationBarIsVisible; } } if (null != _frame) { _frame.OrientationChanged -= HandleFrameOrientationChanged; } } if ((ListPickerMode.Expanded == oldValue) || (ListPickerMode.Full == oldValue)) { if (null != _page) { _page.BackKeyPress -= HandlePageBackKeyPress; _page = null; } } // Hook up to relevant events if ((ListPickerMode.Expanded == newValue) || (ListPickerMode.Full == newValue)) { if (null != _frame) { _page = _frame.Content as PhoneApplicationPage; if (null != _page) { _page.BackKeyPress += HandlePageBackKeyPress; } } } if ((ListPickerMode.Full == newValue) && !DesignerProperties.IsInDesignTool) { Action saveTrayAndHide = () => { try { _savedSystemTrayIsVisible = SystemTray.IsVisible; SystemTray.IsVisible = false; } catch (InvalidOperationException) { } }; try { saveTrayAndHide(); } catch (InvalidOperationException) { Dispatcher.BeginInvoke(saveTrayAndHide); } if (null != _frame) { AdjustPopupChildForCurrentOrientation(_frame); _frame.OrientationChanged += HandleFrameOrientationChanged; if (null != _page) { if (null != _page.ApplicationBar) { _savedApplicationBarIsVisible = _page.ApplicationBar.IsVisible; _page.ApplicationBar.IsVisible = false; } } } if (null != _fullModeSelectorPart) { _fullModeSelectorPart.ItemsSource = Items; _fullModeSelectorPart.SelectionChanged += HandleFullModeSelectorPartSelectionChanged; _fullModeSelectorPart.Loaded += HandleFullModeSelectorPartLoaded; } if (null != _fullModePopupPart) { _fullModePopupPart.IsOpen = true; } } // Resize for new view and go to relevant visual state(s) SizeForAppropriateView(ListPickerMode.Full != oldValue); GoToStates(true); }
private void OnListPickerModeChanged(ListPickerMode oldValue, ListPickerMode newValue) { if ((ListPickerMode.Expanded == oldValue)) { if (null != _page) { _page.BackKeyPress -= HandlePageBackKeyPress; _page = null; } if (null != _frame) { _frame.ManipulationStarted -= HandleFrameManipulationStarted; _frame = null; } } if (ListPickerMode.Expanded == newValue) { // Hook up to frame if not already done if (null == _frame) { _frame = Application.Current.RootVisual as PhoneApplicationFrame; if (null != _frame) { _frame.AddHandler(ManipulationStartedEvent, new EventHandler<ManipulationStartedEventArgs>(HandleFrameManipulationStarted), true); } } if (null != _frame) { _page = _frame.Content as PhoneApplicationPage; if (null != _page) { _page.BackKeyPress += HandlePageBackKeyPress; } } } if (ListPickerMode.Full == oldValue) { ClosePickerPage(); } if (ListPickerMode.Full == newValue) { OpenPickerPage(); } SizeForAppropriateView(ListPickerMode.Full != oldValue); IsHighlighted = (ListPickerMode.Expanded == newValue); }
private void OnListPickerModeChanged(ListPickerMode oldValue, ListPickerMode newValue) { // Hook up to frame if not already done if (null == _frame) { _frame = Application.Current.RootVisual as PhoneApplicationFrame; if (null != _frame) { _frame.AddHandler(ManipulationCompletedEvent, new EventHandler<ManipulationCompletedEventArgs>(HandleFrameManipulationCompleted), true); } } // Restore state if ((ListPickerMode.Full == oldValue) && !DesignerProperties.IsInDesignTool) { if (null != _fullModePopupPart) { _fullModePopupPart.IsOpen = false; } if (null != _fullModeSelectorPart) { _fullModeSelectorPart.SelectionChanged -= HandleFullModeSelectorPartSelectionChanged; _fullModeSelectorPart.Loaded -= HandleFullModeSelectorPartLoaded; _fullModeSelectorPart.ItemsSource = null; } Action restoreSystemTray = () => { try { SystemTray.IsVisible = _savedSystemTrayIsVisible; } catch (InvalidOperationException) { } }; try { restoreSystemTray(); } catch (InvalidOperationException) { Dispatcher.BeginInvoke(restoreSystemTray); } if (null != _page) { if (null != _page.ApplicationBar) { _page.ApplicationBar.IsVisible = _savedApplicationBarIsVisible; } } if (null != _frame) { _frame.OrientationChanged -= HandleFrameOrientationChanged; } } if ((ListPickerMode.Expanded == oldValue) || (ListPickerMode.Full == oldValue)) { if (null != _page) { _page.BackKeyPress -= HandlePageBackKeyPress; _page = null; } } // Hook up to relevant events if ((ListPickerMode.Expanded == newValue) || (ListPickerMode.Full == newValue)) { if (null != _frame) { _page = _frame.Content as PhoneApplicationPage; if (null != _page) { _page.BackKeyPress += HandlePageBackKeyPress; } } } if ((ListPickerMode.Full == newValue) && !DesignerProperties.IsInDesignTool) { Action saveTrayAndHide = () => { try { _savedSystemTrayIsVisible = SystemTray.IsVisible; SystemTray.IsVisible = false; } catch (InvalidOperationException) { } }; try { saveTrayAndHide(); } catch (InvalidOperationException) { Dispatcher.BeginInvoke(saveTrayAndHide); } if (null != _frame) { AdjustPopupChildForCurrentOrientation(_frame); _frame.OrientationChanged += HandleFrameOrientationChanged; if (null != _page) { if (null != _page.ApplicationBar) { _savedApplicationBarIsVisible = _page.ApplicationBar.IsVisible; _page.ApplicationBar.IsVisible = false; } } } if (null != _fullModeSelectorPart) { _fullModeSelectorPart.ItemsSource = Items; _fullModeSelectorPart.SelectionChanged += HandleFullModeSelectorPartSelectionChanged; _fullModeSelectorPart.Loaded += HandleFullModeSelectorPartLoaded; } if (null != _fullModePopupPart) { _fullModePopupPart.IsOpen = true; } } // Resize for new view and go to relevant visual state(s) SizeForAppropriateView(ListPickerMode.Full != oldValue); GoToStates(true); }