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

Arrow cue - graphic problem

4 Answers 43 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Tim Tos
Top achievements
Rank 1
Tim Tos asked on 07 Aug 2010, 02:55 AM
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.

4 Answers, 1 is accepted

Sort by
0
Accepted
Tsvyatko
Telerik team
answered on 10 Aug 2010, 12:46 PM
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
0
Tim Tos
Top achievements
Rank 1
answered on 10 Aug 2010, 01:00 PM
Hello Tsvyatko,

thanks a lot!!! That did the trick!
Best wishes,
Tim.
0
Andrew
Top achievements
Rank 1
answered on 22 Mar 2011, 09:37 AM

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;
   }
}

0
Ivan Ivanov
Telerik team
answered on 24 Mar 2011, 04:44 PM
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
Tags
DragAndDrop
Asked by
Tim Tos
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Tim Tos
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or