wrong source&destination items with TreeView

2 posts, 1 answers
  1. Adrien
    Adrien avatar
    2 posts
    Member since:
    May 2009

    Posted 18 May 2009 Link to this post

    I want to drag & drop between two treeviews, but I rarely have the items I want. Often the source (e.Options.Source) is the root item of my treeview or sometimes the parent item of the item wanted. The same thing happens for the destination on drop.

    Do you know what might cause the problem ?

    Here is an example to reproduce the problem, with a visualization of the source item while dragging. When dragging

    <UserControl x:Class="SilverlightApplication1.Page"  
        Width="600" Height="400"
        <Grid x:Name="LayoutRoot" Background="White"
            <StackPanel Orientation="Horizontal"
                <telerikNavigation:RadTreeView x:Name="xTreeView" IsEditable="True"
                        <Style TargetType="telerikNavigation:RadTreeViewItem"
                            <Setter Property="telerikDragDrop:RadDragAndDropManager.AllowDrag" Value="True" /> 
                            <Setter Property="telerikDragDrop:RadDragAndDropManager.AllowDrop" Value="True" /> 
                            <Setter Property="IsExpanded" Value="True" /> 
                    <telerikNavigation:RadTreeViewItem Header="Root"
                        <telerikNavigation:RadTreeViewItem Header="Folder"
                            <telerikNavigation:RadTreeViewItem Header="File" /> 
                            <telerikNavigation:RadTreeViewItem Header="File" /> 

    using System; 
    using System.Windows; 
    using System.Windows.Controls; 
    using System.Windows.Media; 
    using Telerik.Windows; 
    using Telerik.Windows.Controls; 
    using Telerik.Windows.Controls.DragDrop; 
    namespace SilverlightApplication1 
        public partial class Page : UserControl 
            public Page() 
                xTreeView.AddHandler(RadDragAndDropManager.DragQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnTreeDragQuery), false); 
            private void OnTreeDragQuery(object sender, DragDropQueryEventArgs e) 
                RadTreeViewItem vControlItem = e.Options.Source as RadTreeViewItem; 
                if (e.Options.Status == DragStatus.DragQuery) 
                    if (vControlItem != null
                        e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue(); 
                        TextBlock vPreview = new TextBlock(); 
                        vPreview.Text = vControlItem.Header.ToString(); 
                        vPreview.Foreground = new SolidColorBrush(Colors.Blue); 
                        vPreview.FontWeight = FontWeights.Bold; 
                        vPreview.Opacity = 0.6; 
                        e.Options.Payload = vControlItem; 
                        e.Options.DragCue = vPreview; 
                        e.QueryResult = true
                        e.Handled = true
                        e.QueryResult = false
                        e.Handled = false

  2. Answer
    Miroslav avatar
    922 posts

    Posted 19 May 2009 Link to this post

    Hello Adrien,

    I confirmed that this is indeed the case. The bug is now fixed and will finds its way in the next Latest Internal Buid and consecutive releases (you should have the update by the end of this week).

    As a temporary workaround, I can suggest to use the SelectedItems of the TreeView and assign them as a Payload.

    Thank you for your feedback, your Telerik Points have been updated.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top