private static ListBoxDragDropBehavior GetAttachedBehavior(System.Windows.Controls.ListBox listBox) { if (!instances.ContainsKey(listBox)) { instances[listBox] = new ListBoxDragDropBehavior(); instances[listBox].AssociatedObject = listBox; } return(instances[listBox]); }
public static void SetIsEnabled(DependencyObject obj, bool value) { ListBoxDragDropBehavior behavior = GetAttachedBehavior(obj as System.Windows.Controls.ListBox); behavior.AssociatedObject = obj as System.Windows.Controls.ListBox; if (value) { behavior.Initialize(); } else { behavior.CleanUp(); } obj.SetValue(IsEnabledProperty, value); }