static void OnAllowDropChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { UIElement target = sender as UIElement; if ((bool)e.NewValue) { DragManager.SetDropTargetFactory(target, new DragAndDropTargetFactory(target)); } else { DragManager.SetDropTargetFactory(target, null); } }