Getting wpf gridid

If in my wpf application there are several grids and a user-controlled control. Can someone suggest code that could return a different grid identifier each time the control is dragged through different grids.

+4
source share
1 answer

You can use Mouse.DirectlyOver , then go to the visual tree to find the first Grid before the tree.

Mouse.DirectlyOver returns the IInputElement that is under the mouse when you check the property.

You can approach the visual tree using the method described in this SO question

Edit: I found the SO question about the visual processing of the tree that I was thinking about. (much better than the first IMHO link).

+4
source

Source: https://habr.com/ru/post/1385172/


All Articles