/// <summary> /// Registeres a handler for the UI element type defined by it 'Type' property /// </summary> /// <remarks> /// If a handler was registered before for the exact same type (e.g. one of the default handlers), /// it is removed and replaced by the handler given /// </remarks> public static void RegisterDragDropUITargetHandler(IDragDropUiTargetHandler handler) { if (DragDrop.dragTargetHandlers.ContainsKey(handler.Type)) { DragDrop.dragTargetHandlers.Remove(handler.Type); } DragDrop.dragTargetHandlers.Add(handler.Type, handler); }
/// <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); }