//private readonly Popup popup = new Popup(); //private Point dragLocation; private DragDropTargetAdapter(IDragDropTarget targetHandler, DependencyObject target, bool makeDroppable) { this.targetHandler = targetHandler; this.target = target; this.dragTargetHandler = DragDrop.GetDragDropUITargetHandler(target.GetType()).Create(target, this, makeDroppable); System.Windows.DragDrop.AddDragEnterHandler(this.target, this.DragEnter); System.Windows.DragDrop.AddDragLeaveHandler(this.target, this.DragLeave); System.Windows.DragDrop.AddDragOverHandler(this.target, this.DragOver); System.Windows.DragDrop.AddDropHandler(this.target, this.Drop); /* * this.popup.AllowsTransparency = true; * ContentControl Content = new ContentControl(); * Content.SetBinding(ContentControl.ContentProperty, ""); * Border Border = new Border(); * Border.BorderThickness = new Thickness(1); * Border.CornerRadius = new CornerRadius(3); * Border.BorderBrush = new SolidColorBrush(SystemColors.HighlightColor) { Opacity = 0.7 }; * Border.Background = new SolidColorBrush(SystemColors.HighlightColor) {Opacity = 0.3}; * Border.Child = Content; * Border.MinHeight = 10; * Border.MinWidth = 10; * this.popup.Child = Border; * this.popup.Placement = PlacementMode.Custom; * this.popup.CustomPopupPlacementCallback = this.HandlePopupPlacement; * this.popup.HorizontalOffset = 10; * this.popup.VerticalOffset = 10;*/ }
/// <summary> /// Notifies the handler, that a drag operation has started above the control /// </summary> /// <param name="effect"></param> public void NotifyDragStarted(DragDropEffect effect) { TabPanel TabPanel = this.element.GetVisualDescendantsDepthFirst <TabPanel>().FirstOrDefault(); if (TabPanel != null) { IDragDropUiTargetHandler Handler = DragDrop.GetDragDropUITargetHandler(TabPanel.GetType()); if (Handler != null) { this.panelTargetHandler = Handler.Create(TabPanel, this.adapter, false); } } if (this.panelTargetHandler == null) { this.panelTargetHandler = new DummyUiHandler(); } this.panelTargetHandler.NotifyDragStarted(effect); }
/// <summary> /// Notifies the handler, that a drag operation has started above the control /// </summary> /// <param name="effect"></param> public void NotifyDragStarted(DragDropEffect effect) { ItemsPresenter ItemsPresenter = this.element.GetVisualDescendantsDepthFirst <ItemsPresenter>().FirstOrDefault(); if (ItemsPresenter != null) { Panel ItemsPanel = VisualTreeHelper.GetChild(ItemsPresenter, 0) as Panel; if (ItemsPanel != null) { IDragDropUiTargetHandler Handler = DragDrop.GetDragDropUITargetHandler(ItemsPanel.GetType()); if (Handler != null) { this.panelTargetHandler = Handler.Create(ItemsPanel, this.adapter, false); } } } if (this.panelTargetHandler == null) { this.panelTargetHandler = new DummyUiHandler(); } this.panelTargetHandler.NotifyDragStarted(effect); }
/// <summary> /// Notifies the handler, that a drag operation has ended above the control, either because /// the item was dropped, or because the mouse left the controls area /// </summary> public void NotifyDragEnded() { this.panelTargetHandler.NotifyDragEnded(); this.panelTargetHandler.Dispose(); this.panelTargetHandler = null; }