VisualCue shifted from mouse

4 posts, 1 answers
  1. Vit100
    Vit100 avatar
    66 posts
    Member since:
    Oct 2012

    Posted 02 Jul 2012 Link to this post

    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?

  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 03 Jul 2012 Link to this post

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

  3. DevCraft banner
  4. Vit100
    Vit100 avatar
    66 posts
    Member since:
    Oct 2012

    Posted 03 Jul 2012 Link to this post

    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


  5. Answer
    Nick
    Admin
    Nick avatar
    593 posts

    Posted 06 Jul 2012 Link to this post

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

Back to Top