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

VisualCue shifted from mouse

3 Answers 53 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Vit100
Top achievements
Rank 1
Vit100 asked on 02 Jul 2012, 11:10 PM
Hey
I've noticed strange thing
if i start drag operation of button from right tide of button arrowCue is next to VisualCue (left picture)

If I start from left side - arrowCue shifted (right picture)
Any ideas?

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 03 Jul 2012, 01:46 PM
Hi Vitaliy,

The behavior you are experiencing is indeed strange? May I ask you to provide more detailed information about the exact drag and drop implementation you are using? Do you set a DragCueOffset at the beginning of the drag operation? 

Looking forward to hearing from you! 

Greetings,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Vit100
Top achievements
Rank 1
answered on 03 Jul 2012, 03:29 PM
Nothing special:
<Grid x:Name="LayoutRoot" Background="White">
        <Button Content="ccccccccccc"
                telerik:RadDragAndDropManager.AllowDrag="True"
                Height="23" HorizontalAlignment="Left" Margin="51,12,0,0" Name="button1" VerticalAlignment="Top" Width="75"  />
        
         
        <ListBox
            telerik:RadDragAndDropManager.AllowDrop="True"
            Height="87" HorizontalAlignment="Left" Margin="90,0,0,41" Name="listBox1" VerticalAlignment="Bottom" Width="236" />
    </Grid>

and code behind:
public MainPage()
        {
            InitializeComponent();
            RadDragAndDropManager.AddDragQueryHandler(this, OnDragQuery);
            RadDragAndDropManager.AddDropQueryHandler(this, OnDropQuery);
        }
  
        private void OnDropQuery(object sender, DragDropQueryEventArgs e)
        {
            e.QueryResult = true;
        }
  
        private void OnDragQuery(object sender, DragDropQueryEventArgs e)
        {
             if (e.Options.Status == DragStatus.DragQuery)
            {
                e.QueryResult = true;
                e.Options.DragCue = RadDragAndDropManager.GenerateVisualCue(e.Options.Source);
 
                var arrowCue = RadDragAndDropManager.GenerateArrowCue();
                e.Options.ArrowCue = arrowCue;
            }
            e.Handled = true;
        }


Test project is here: 
https://skydrive.live.com/redir?resid=17FEEB61AFE2DBEB!14919&authkey=!AH3czBO5Lq7skuA


0
Accepted
Nick
Telerik team
answered on 06 Jul 2012, 10:58 AM
Hello Vitaliy,

The reason for the issue is that you are using the GenerateVisualCue method, which basically creates an empty cue with the same size and margins that the given parameter has. Therefore the buttons margin is applied to the VisualCue resulting in the experienced behavior.

Here is how you can fix the issue:

private void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
 
    if (e.Options.Status == DragStatus.DragQuery)
    {
        e.QueryResult = true;
 
        var cue = RadDragAndDropManager.GenerateVisualCue(e.Options.Source);
        cue.Margin = new Thickness(0);
        e.Options.DragCue = cue;
 
        var arrowCue = RadDragAndDropManager.GenerateArrowCue();
        e.Options.ArrowCue = arrowCue;
    }
    e.Handled = true;
}

Hope this helps! Let me know if there is anything more I can help you with!  All the best,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
DragAndDrop
Asked by
Vit100
Top achievements
Rank 1
Answers by
Nick
Telerik team
Vit100
Top achievements
Rank 1
Share this question
or