/// <summary> /// Handles the PreviewMouseLeftButtonDown event on the drag source. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event args.</param> private void DragSourcePreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this.sourceItemsControl = (TreeListBox)sender; var visual = e.OriginalSource as Visual; this.topWindow = Window.GetWindow(this.sourceItemsControl); this.initialMousePosition = e.GetPosition(this.topWindow); this.sourceItemContainer = visual != null ? this.sourceItemsControl.ContainerFromElement(visual) as TreeListBoxItem : null; if (this.sourceItemContainer != null) { this.draggedData = new List <IDragSource>(); this.draggedData.Add(this.sourceItemContainer.DataContext); // todo: how to drag multiple items? // must set e.Handled = true to avoid items being deselected // foreach (var si in sourceItemsControl.SelectedItems) this.draggedData.Add(si); } else { this.draggedData = null; } }
/// <summary> /// Handles the PreviewDragEnter event on the drop target. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event args.</param> private void DropTargetPreviewDragEnter(object sender, DragEventArgs e) { this.targetItemsControl = (TreeListBox)sender; object draggedItems = e.Data.GetData(this.format.Name); if (draggedItems != null) { this.DecideDropTarget(e); this.UpdateAdorner(); e.Handled = true; } }
/// <summary> /// Handles the PreviewDragEnter event on the drop target. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The event args. /// </param> private void DropTargetPreviewDragEnter(object sender, DragEventArgs e) { this.targetItemsControl = (TreeListBox)sender; object draggedItems = e.Data.GetData(this.format.Name); if (draggedItems != null) { this.DecideDropTarget(e); this.UpdateAdorner(); e.Handled = true; } }
/// <summary> /// Handles the PreviewMouseLeftButtonDown event on the drag source. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The event args. /// </param> private void DragSourcePreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this.sourceItemsControl = (TreeListBox)sender; var visual = e.OriginalSource as Visual; this.topWindow = Window.GetWindow(this.sourceItemsControl); this.initialMousePosition = e.GetPosition(this.topWindow); this.sourceItemContainer = visual != null ? this.sourceItemsControl.ContainerFromElement(visual) as TreeListBoxItem : null; if (this.sourceItemContainer != null) { this.draggedData = new List<IDragSource>(); this.draggedData.Add(this.sourceItemContainer.DataContext); // todo: how to drag multiple items? // must set e.Handled = true to avoid items being deselected // foreach (var si in sourceItemsControl.SelectedItems) this.draggedData.Add(si); } else { this.draggedData = null; } }
/// <summary> /// Initializes a new instance of the <see cref="TreeListBoxAutomationPeer"/> class. /// </summary> /// <param name="owner">The owner.</param> public TreeListBoxAutomationPeer(TreeListBox owner) : base(owner) { }
/// <summary> /// Initializes a new instance of the <see cref="TreeListBoxItem"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> public TreeListBoxItem(TreeListBox parent) { // The following is not working when TreeListBoxItems are disconnected... // ItemsControl.ItemsControlFromItemContainer(this) as TreeListBox; this.ParentTreeListBox = parent; this.ChildItems = new List<TreeListBoxItem>(); }
/// <summary> /// Initializes a new instance of the <see cref="TreeListBoxAutomationPeer"/> class. /// </summary> /// <param name="owner">The owner.</param> public TreeListBoxAutomationPeer(TreeListBox owner) : base(owner) { }