This is a migrated thread and some comments may be shown as answers.

e.Options.Destination property always returns tree root node.

1 Answer 58 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
SangGyu Kim
Top achievements
Rank 1
SangGyu Kim asked on 05 Oct 2009, 11:49 AM
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?

 

        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> 

1 Answer, 1 is accepted

Sort by
0
SangGyu Kim
Top achievements
Rank 1
answered on 05 Oct 2009, 03:43 PM
I solve the problem. ^^
Sub item nodes are created dynamically and I didn't set RadDragAndDropManager.AllowDropProperty property value.

                foreach (SPStorageItem item in dirs.Where(o => o.IsFolder))  
                {  
                    TreeViewItem item2 = new TreeViewItem();  
                    item2.DataContext = item;  
                    item2.SetValue(RadDragAndDropManager.AllowDropProperty, true);  
                    treeViewItem.Items.Add(item2);  
                } 
Tags
DragAndDrop
Asked by
SangGyu Kim
Top achievements
Rank 1
Answers by
SangGyu Kim
Top achievements
Rank 1
Share this question
or