private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue) { var element = (ItemsControl)d; var behavior = new ListItemMoveBehavior(element); SetBehavior(element, behavior); } else { GetBehavior(d).Dispose(); d.ClearValue(BehaviorProperty); } }
private static void SetBehavior(DependencyObject obj, ListItemMoveBehavior value) { obj.SetValue(BehaviorProperty, value); }