Arrow cue - graphic problem

5 posts, 1 answers
  1. Tim Tos
    Tim Tos avatar
    36 posts
    Member since:
    Apr 2010

    Posted 06 Aug 2010 Link to this post

    Hello!

    I am currently evaluating the DragAndDrop-Functionality - unfortunately I ran into some kind of graphic invalidation problem.
    I am dragging from a custom usercontrol to a RadTreeView that's a child of a RadExpander. A snapshot of the result is attached as a png file. Has anyone experienced such a behavior? What am I doing wrong? Or is it a bug?

    My code is very simple! I just activate the DragAndDrop-Functionality, register the events and then for the source and the destination in the code-behind:
    Source:
    private void OnDragQuery(object sender, DragDropQueryEventArgs e)
    {
        e.Options.DragCue = RadDragAndDropManager.GenerateVisualCue();
        e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
        e.Options.Payload = "Hello World";
        e.QueryResult = true;
        e.Handled = true;
    }

    Destination:
    private void OnDropQuery(object sender, DragDropQueryEventArgs e)
    {
        e.QueryResult = true;
        e.Handled = true;
    }
      
    private void OnDropInfo(object sender, DragDropEventArgs e)
    {
        string payload = e.Options.Payload.ToString();
      
        if (e.Options.Status == DragStatus.DropComplete)
            this.myTreeView.Items.Add(payload);
    }

    That's all. Any ideas?
    Thanks a lot,
    Tim.
  2. Answer
    Tsvyatko
    Admin
    Tsvyatko avatar
    832 posts

    Posted 10 Aug 2010 Link to this post

    Hi Tim Tos,

    Could you please try to wrap the logic for creating the Visual and Arrow Cue in this code:
      if (args.Options.Status == DragStatus.DragQuery){
    ...
    }

    Please, let me know, if you have further problems.

    Best wishes,
    Tsvyatko
    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
  3. DevCraft banner
  4. Tim Tos
    Tim Tos avatar
    36 posts
    Member since:
    Apr 2010

    Posted 10 Aug 2010 Link to this post

    Hello Tsvyatko,

    thanks a lot!!! That did the trick!
    Best wishes,
    Tim.
  5. Andrew
    Andrew avatar
    20 posts
    Member since:
    Mar 2010

    Posted 22 Mar 2011 Link to this post

    Hello,

    I want to add ArrowCue to the RadTreeView. I do this in OnDragQuery event but e.Options.Status is always DropImpossible. Am I doing something wrong?


    This is my code:

    <Grid x:Name="LayoutRoot" Background="White">
       <Grid.RowDefinitions>
          <RowDefinition Height="*" />
          <RowDefinition Height="20" />
       </Grid.RowDefinitions>
             
       <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="*" />
       </Grid.ColumnDefinitions>
             
       <telerik:RadTreeView Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" x:Name="radTreeView1">
          <telerik:RadTreeViewItem DropPosition="Inside" Header="Item 1" TabNavigation="Once" />
          <telerik:RadTreeViewItem DropPosition="Inside" Header="Item 2" TabNavigation="Once" />
          <telerik:RadTreeViewItem DropPosition="Inside" Header="Item 3" TabNavigation="Once" />
          <telerik:RadTreeViewItem DropPosition="Inside" Header="Item 4" TabNavigation="Once" />
          <telerik:RadTreeViewItem DropPosition="Inside" Header="Item 5" TabNavigation="Once" />
       </telerik:RadTreeView>
             
       <TextBlock Grid.Row="1" Grid.Column="0" x:Name="tbDragQuery" Text="DragQuery status: " />
       <TextBlock Grid.Row="1" Grid.Column="1" x:Name="tbDragInfo" Text="DragInfo status: " />
       <TextBlock Grid.Row="1" Grid.Column="2" x:Name="tbDropQuery" Text="DropQuery status: " />
       <TextBlock Grid.Row="1" Grid.Column="3" x:Name="tbDropInfo" Text="DropInfo status: " />
    </Grid>

    public MainPage()
    {
       InitializeComponent();
     
       radTreeView1.IsDragDropEnabled = true;
     
       RadDragAndDropManager.AddDragQueryHandler(this.radTreeView1, OnDragQuery);
       RadDragAndDropManager.AddDragInfoHandler(this.radTreeView1, OnDragInfo);
       RadDragAndDropManager.AddDropQueryHandler(this.radTreeView1, OnDropQuery);
       RadDragAndDropManager.AddDropInfoHandler(this.radTreeView1, OnDropInfo);
    }
     
    private void OnDragQuery(object sender, DragDropQueryEventArgs e)
    {
       tbDragQuery.Text = "DragQuery status: " + e.Options.Status.ToString();
     
       if (e.Options.Source is RadTreeViewItem)
       {
          RadTreeView tree = sender as RadTreeView;
          if (e.Options.Status == DragStatus.DragQuery && tree != null)
          {
             e.Options.Payload = tree.SelectedItems;
             e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
             (e.Options.DragCue as TreeViewDragCue).ItemTemplate =
                (DataTemplate)System.Windows.Markup.XamlReader.Load("<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><Image Source=\"/../../Img/Dashboard48.png\" Stretch=\"None\" VerticalAlignment=\"Top\" /></DataTemplate>");
          }
          e.QueryResult = true;
          e.Handled = true;
       }
    }
     
    private void OnDragInfo(object sender, DragDropEventArgs e)
    {
       tbDragInfo.Text = "DragInfo status: " + e.Options.Status.ToString();
    }
     
    private void OnDropQuery(object sender, DragDropQueryEventArgs e)
    {
       tbDropQuery.Text = "DropQuery status: " + e.Options.Status.ToString();
    }
     
    private void OnDropInfo(object sender, DragDropEventArgs e)
    {
       tbDropInfo.Text = "DropInfo status: " + e.Options.Status.ToString();
     
       TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;
       if (e.Options.Status == DragStatus.DropPossible)
       {
          cue.DragActionContent = String.Format("Move here: ");
          cue.IsDropPossible = true;
       }
       else if (e.Options.Status == DragStatus.DropImpossible)
       {
          cue.DragActionContent = null;
          cue.IsDropPossible = false;
       }
    }

  6. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 24 Mar 2011 Link to this post

    Hello Tim Tos,

    I have prepared a sample project, similar to the one you have sent to me. Telerik RadTreeView internally handles drag and drop events. In order to subscribe to one, you should utilize the technique, demonstrated in the project. Please, have in mind that you should import Telerik.Windows namespace to enable the usage of our AddHandler(Telerik.Windows.RoutedEvent, ...) extension method, instead of AddHandler(System.Windows.RoutedEvent, ...).


    All the best,
    Ivan Ivanov
    the Telerik team
Back to Top
DevCraft banner