This question is locked. New answers and comments are not allowed.
I find strange thing in Drop Query Handler Method to drop the TreeView Control (not RadTreeView)
e.Options.Destination property always returns tree root node
How can I get the TreeViewItem object that I dropped?
e.Options.Destination property always returns tree root node
How can I get the TreeViewItem object that I dropped?
| private void OnTreeDropQuery(object sender, DragDropQueryEventArgs e) |
| { |
| var destinationItem = e.Options.Destination as TreeViewItem; <-- always returns "Root" node item |
| var sourceItem = e.Options.Source as Control; |
| Debug.WriteLine("OnTreeDropQuery " + ((Label)((StackPanel)destinationItem.Header).Children[1]).Content); |
| if (e.Options.Status == DragStatus.DropDestinationQuery) |
| { |
| if (destinationItem != null && destinationItem != sourceItem) |
| { |
| //Debug.WriteLine("OnTreeDropQuery Drop Query Item Tag :" + destinationItem); |
| var storageItem = destinationItem.DataContext as SPStorageItem; |
| var isStorageItemNode = storageItem != null; |
| e.QueryResult = isStorageItemNode; |
| e.Handled = isStorageItemNode; |
| } |
| else |
| { |
| e.QueryResult = false; |
| } |
| } |
| } |
| <basics:TreeView x:Name="tvNavigation" GotFocus="tvNavigation_GotFocus" SelectedItemChanged="tvNavigatin_SelectedItemChanged" |
| Grid.Row="2" |
| Grid.Column="0" |
| VerticalAlignment="Stretch" |
| HorizontalAlignment="Stretch" |
| KeyUp="tvNavigation_KeyUp" |
| KeyDown="tvNavigation_KeyDown" |
| > |
| <basics:TreeView.ItemContainerStyle> |
| <Style TargetType="basics:TreeViewItem"> |
| <Setter Property="dragDrop:RadDragAndDropManager.AllowDrag" Value="True" /> |
| <Setter Property="dragDrop:RadDragAndDropManager.AllowDrop" Value="True" /> |
| <Setter Property="Foreground" Value="Red" /> |
| </Style> |
| </basics:TreeView.ItemContainerStyle> |
| <basics:TreeViewItem IsExpanded="True" Tag="My Computer" > |
| <basics:TreeViewItem.Header> |
| <StackPanel Orientation="Horizontal"> |
| <Image Source="../../Image/computer24.png"></Image> |
| <Controls:Label Content=" My Computer" VerticalAlignment="Center"></Controls:Label> |
| </StackPanel> |
| </basics:TreeViewItem.Header> |
| <basics:TreeViewItem Tag="Online" > |
| <basics:TreeViewItem.Header> |
| <StackPanel Orientation="Horizontal"> |
| <Image Source="../../Image/disc24.png"></Image> |
| <Controls:Label Content=" Online Storage"></Controls:Label> |
| </StackPanel> |
| </basics:TreeViewItem.Header> |
| </basics:TreeViewItem> |
| <basics:TreeViewItem Tag="Local"> |
| <basics:TreeViewItem.Header> |
| <StackPanel Orientation="Horizontal"> |
| <Image Source="../../Image/mydoc24.png"></Image> |
| <Controls:Label Content=" Offline Storage"></Controls:Label> |
| </StackPanel> |
| </basics:TreeViewItem.Header> |
| </basics:TreeViewItem> |
| <basics:TreeViewItem Tag="휴지통"> |
| <basics:TreeViewItem.Header> |
| <StackPanel Orientation="Horizontal"> |
| <Image Source="../../Image/recyclebin24.png"></Image> |
| <Controls:Label Content=" 휴지통" VerticalAlignment="Center"></Controls:Label> |
| </StackPanel> |
| </basics:TreeViewItem.Header> |
| </basics:TreeViewItem> |
| </basics:TreeViewItem> |
| </basics:TreeView> |