/// <summary> /// Handles changes to the Parent property. /// </summary> private static void OnParentCollectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FilterControl target = (FilterControl)d; IEnumerable oldParent = (IEnumerable)e.OldValue; IEnumerable newParent = (IEnumerable)e.NewValue; target.OnParentCollectionChanged(oldParent, newParent); }
/// <summary> /// Handles changes to the Key property. /// </summary> private static void OnKeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FilterControl target = (FilterControl)d; if (!isInDesignMode && target.Model != null) { throw new InvalidOperationException("Change Key after FilterControl was attached to FilterPresenter not allowed."); } string oldKey = (string)e.OldValue; string newKey = (string)e.NewValue; target.OnKeyChanged(oldKey, newKey); }
/// <summary> /// Handles changes to the FilterInitializersManager property. /// </summary> private static void OnFilterInitializersManagerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FilterControl target = (FilterControl)d; if (!isInDesignMode && target.Model != null) { throw new InvalidOperationException("Change Key after FilterControl was attached to FilterPresenter not allowed."); } FilterInitializersManager oldFilterInitializersManager = (FilterInitializersManager)e.OldValue; FilterInitializersManager newFilterInitializersManager = (FilterInitializersManager)e.NewValue; target.OnFilterInitializersManagerChanged(oldFilterInitializersManager, newFilterInitializersManager); }
/// <summary> /// Handles changes to the Model property. /// </summary> private static void OnModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FilterControl target = (FilterControl)d; FilterControlVm oldModel = (FilterControlVm)e.OldValue; if (oldModel != null) { oldModel.Dispose(); oldModel.StateChanged -= target.OnStateChanged; target.ItemsSource = null; } FilterControlVm newModel = target.Model; if (newModel != null) { newModel.StateChanged += target.OnStateChanged; target.ItemsSource = newModel; target.SetVisualState(newModel.State); } target.OnModelChanged(newModel); }