/// <summary> /// Property Changed Callback method of the IsSelected Dependency Property. /// </summary> /// <param name="sender">The instance of the class that had the IsSelected property changed.</param> /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> private static void OnIsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { PageViewerItem subject = (PageViewerItem)sender; bool newValue = (bool)e.NewValue; bool oldValue = (bool)e.OldValue; if (!(subject.Owner == null || subject.Owner.IsSettingSelection)) { if (newValue) { subject.Owner.SelectedItem = subject; } else if (subject.Owner.SelectedItem == subject) { subject.Owner.SelectedItem = null; } } }
/// <summary> /// Property Changed Callback method of the SelectedItem Dependency Property. /// </summary> /// <param name="sender">The instance of the class that had the SelectedItem property changed.</param> /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { PageViewer subject = (PageViewer)sender; PageViewerItem newValue = (PageViewerItem)e.NewValue; PageViewerItem oldValue = (PageViewerItem)e.OldValue; subject.IsSettingSelection = true; if (oldValue != null) { oldValue.FreeContent(); oldValue.IsSelected = false; } if (newValue != null) { newValue.InitializeContent(); newValue.IsSelected = true; } subject.IsSettingSelection = false; }