0

I'm trying to implement a drag-drop function to a usercontrol.

I've managed to get this working properly with the use of google, however, when dropping a control I wish to find every similar type controls that might be or might not be under it.

My current way would be check every control and see if it's under the dropped control. But I wonder if there is a better way, like a find control function which can check for controls within a given range?

Theun Arbeider
  • 5,259
  • 11
  • 45
  • 68
  • ¿Do you mean walk trough the Logical Tree? – NestorArturo Jan 13 '12 at 15:07
  • I might be meaning walk through the logical tree if I were to know what the logical tree is. But it is as I said in my post. Iwant to find controls which are at the same coordinates of the application where I drop my control without having to check every single control. – Theun Arbeider Jan 13 '12 at 15:26

2 Answers2

1

you could use this function: http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper.findelementsinhostcoordinates%28v=vs.95%29.aspx

void xy_MouseMove(object sender, MouseEventArgs e)
    {
        if (m_IsDraging)
        {
            var res = VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition(null), elemenetWhichChildrenYouWantToCheck);
            //... check res for drop elements and react
        }
    }

Or you can just use this function only in MouseLeftButtonUp event

aerkain
  • 592
  • 1
  • 4
  • 16
0

Well..

  • First, the Logical Tree is the tree of sub-controls a control is made of.
  • Second, check this post
Community
  • 1
  • 1
NestorArturo
  • 2,476
  • 1
  • 18
  • 21