I need develop functionality to add a new tile to the tilepanel by dragging/dropping from a list box to specific place (between existing tiles) . Would be nice to highlight place of potential drop. Any good code example. I guess it should be very common.
What you are describing is doable but not that trivial. Doing a hittest to determine what tile the mouse is over is not difficult. e.g:
IInputElement mouseOverElement = Mouse.DirectlyOver;
Tile tile = Utilities.GetAncestorFromType(mouseOverElement as DependencyObject, typeof(Tile), true, tc) as Tile;
Then you could insert your new item into the list at that point.
However, if the mouse is between tiles (e.g. if there is some spacing) it is not that easy to determine where you should insert the item. It depends on the layout specified for the tiles.
Thanks it helps ,
Few more questions:
How to determinate a tile’s rectangle (x,y,x1,y1) relative to the panel, when I know mouse position(GetPosition() on Mouse_Move for the TilePanel)? How to highlight some area inside of the Tile panel – let say between two tiles (give an user a clue where tile will be dropped)