Binding TreeViewDragCue ToolTip

2 posts, 0 answers
  1. Steven
    Steven avatar
    35 posts
    Member since:
    Apr 2011

    Posted 13 May 2011 Link to this post

    Good morning,

    How can I bind the ToolTipPreviwItem in the TreeViewDragCue ?

    Because when I select items in my TreeView the TreeViewDragCue ToolTip displays the object name. (namespace.namespace2....Object)


    PS : I am not able to download .zip. Please post a code sample if needed
  2. Petar Mladenov
    Petar Mladenov avatar
    3145 posts

    Posted 18 May 2011 Link to this post

    Hi Steven,

    You can define a custom DragCueTemplate and use it in the DropInfo event handler of  the RadDragAndDropManager. This technique is realized in the code snippets below. Please give it a try and let us know if it fits in your scenario.
            <DataTemplate x:Key="DragCueTemplate">
                <StackPanel Orientation="Vertical">
                    <Rectangle Height="30" Fill="Transparent"></Rectangle>
                    <TextBox Text="{Binding Name}" Height="20" Width="50" Background="AliceBlue" HorizontalAlignment="Left"></TextBox>
                    <Rectangle Height="3" Fill="Transparent" HorizontalAlignment="Left"></Rectangle>
                    <TextBlock Text="==> Drop SomeWhere" Height="20" />
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadTreeView x:Name="radTreeView" Width="300" IsDragDropEnabled="True" 
                                 VerticalAlignment="Top" Background="Aqua" HorizontalAlignment="Left">
                    <telerik:HierarchicalDataTemplate ItemsSource="{Binding Children}">
                        <TextBlock Text="{Binding Name}" />
    public partial class MainPage : UserControl
           public MainPage()
               radTreeView.AddHandler(RadDragAndDropManager.DragInfoEvent, new EventHandler<DragDropEventArgs>(OnDragInfo));
               ObservableCollection<DataItem> rootCollection = new ObservableCollection<DataItem>();
               GenerateCollection(rootCollection, 4);
               radTreeView.ItemsSource = rootCollection;
           private void OnDragInfo(object sender, DragDropEventArgs e)
               if (e.Options.Status == DragStatus.DragInProgress)
                   var draggedItem = e.Options.Source;
                   // Create Drag Cue
                   // 1. Create a ContentControl. It will be used as a DragCue.
                   ContentControl dragCue = new ContentControl();
                   // 2. Set the dragged item to the ContentControl's Content property.
                   dragCue.Content = draggedItem.DataContext;
                   // 3. Use a DataTemplate to "say" how the dragged item will be displayed.MessageBox.Show("ALO");
                   dragCue.ContentTemplate = this.Resources["DragCueTemplate"] as DataTemplate;
                   // 4. Set the ContentControl to the DragDropOptions' DragCue property.
                   e.Options.DragCue = dragCue;
                   // The other code follow here
           private void buttonExpand_Click(object sender, RoutedEventArgs e)
           public void GenerateCollection(ObservableCollection<DataItem> rootCollection, int levels)
               if (levels == 0)
               for (int i = 0; i < 3; i++)
                   DataItem item = new DataItem()
                       Name = String.Format("Item " + i)
               foreach (var dataitem in rootCollection)
                   GenerateCollection(dataitem.Children, levels - 1);
       public class DataItem
           public string Name { get; set; }
           public ObservableCollection<DataItem> Children { get; set; }
           public DataItem()
               this.Children = new ObservableCollection<DataItem>();

    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top