Ejemplo n.º 1
0
        void AssociatedObject_DragEnter(object sender, DragEventArgs e)
        {
            e.Handled = true;

            //initialize adorner manager with the adorner layer of the itemsControl
            if (_insertAdornerManager != null)
            {
                return;
            }
            var s = sender as DataGrid;

            if (s != null)
            {
                _insertAdornerManager = new ListBoxAdornerManager(AdornerLayer.GetAdornerLayer(s));
            }

            if (_dataType != null)
            {
                return;
            }
            //if the DataContext implements IDropable, record the data type that can be dropped
            if (AssociatedObject.DataContext == null)
            {
                return;
            }
            if (AssociatedObject.DataContext as IDropable != null)
            {
                _dataType = ((IDropable)AssociatedObject.DataContext).DataType;
            }
        }
        private void AtDragEnter(object sender, DragEventArgs e)
        {
            if (_dataType == null)
            {
                //if the DataContext implements IDropable, record the data type that can be dropped
                if (AssociatedObject.DataContext != null)
                {
                    if (AssociatedObject.DataContext as IDropable != null)
                    {
                        _dataType = ((IDropable)AssociatedObject.DataContext).DataType;
                    }
                }
            }
            //initialize adorner manager with the adorner layer of the itemsControl
            if (_insertAdornerManager == null)
            {
                _insertAdornerManager = new ListBoxAdornerManager(AdornerLayer.GetAdornerLayer((ItemsControl)sender));
            }

            e.Handled = true;
        }