private void UserControl_DragEnter(object sender, DragEventArgs e) { try { if (_isDragging) { return; } if (e.Data.GetDataPresent("stackPanelDragItem")) { ViewForegroundControlHeader control = sender as ViewForegroundControlHeader; if (control == null) { return; } else if (control.DataContext == null) { return; } ViewModelImagingLayerDragObject dragObject = (ViewModelImagingLayerDragObject)e.Data.GetData("stackPanelDragItem"); ViewModelImagingLayer model = control.DataContext as ViewModelImagingLayer; if (dragObject.ViewModel != model) { control.SetCurrentValue(BackgroundProperty, new SolidColorBrush(Color.FromRgb(100, 100, 100))); _isDragging = true; } } } catch { } }
private void UserControl_DragLeave(object sender, DragEventArgs e) { try { if (_isDragging) { _isDragging = false; ViewForegroundControlHeader control = sender as ViewForegroundControlHeader; control.SetCurrentValue(BackgroundProperty, new SolidColorBrush(Color.FromArgb(0, 0, 0, 0))); } } catch { } }