Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeViewDragItemsCompletedEventArgs.NewParent spec #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions active/TreeView/TreeViewDragItemsCompletedNewParent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Background

TreeView has built-in support for drag&drop reorder but currently there is no easy way to figure out where the item is being dropped.

# Description

TreeView's data usually has hierarchical structure by nature and "index" doesn't work very well in this scenario. Parent + SubIndex is a more accurate way to locate items in TreeView.

A `NewParent` property in TreeViewDragItemsCompletedEventArgs should be sufficient to represent the drop location. To get SubIndex, developers can do NewParent.Children.IndexOf().

# Examples
kaiguo marked this conversation as resolved.
Show resolved Hide resolved

```C#
private void TreeView_DragItemsCompleted(MUXC.TreeView sender, MUXC.TreeViewDragItemsCompletedEventArgs args)
{
var parent = args.NewParent;
}
```

# API Details

```
[webhosthidden]
runtimeclass TreeViewDragItemsCompletedEventArgs
{
...

Object NewParent{ get; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OldParent isn't necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jevan brought this up as well when I talked to him. Sounds like a good thing to have. Will add it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I tried adding it but then I realized you can select multiple items and drag them together, they don't necessarily share the same parent. OldParentItem is probably not applicable here?

Copy link
Author

@kaiguo kaiguo Nov 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we make OldParent a dictionary of selected items and their parents?

kaiguo marked this conversation as resolved.
Show resolved Hide resolved

...
}
```

# Remarks

Similar to other "Item" APIs in TreeView, NewParent returns a loosely typed Object, it can be cast to ItemsSource type when using databinding or TreeViewNode when not using databinding.

# API Notes

## Class: TreeViewDragItemsCompletedEventArgs
| Member Name | Description |
|:- |:--|
| NewParent | Gets the loosely typed object that is the new parent of drag items. |