Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF drag and drop to DataGrid

I have been searching the internet high and low but can't find some examples that can help me.

I'm developing an application in wpf, in it I use a DataGrid; each cell has a DataTemplate with and image, in a mosaic style; on the side of the grid I have some tiles to use on the grid.

I'm able to drag the tiles but can't drop them on the grid because I can't find the cell to which make the drop. Is there a way to get a cell position from the the drag events?

Thanks

like image 585
user267752 Avatar asked Mar 28 '10 18:03

user267752


Video Answer


1 Answers

I am assuming you suscribed to the drop event on the DataGrid.

Since you have a DataTemplate for each cell, you could subscribe to the drop event from the cell and you should be able to do the modification you want via e.Source.

If you need to you could define a different DataTemplate for each column so that you can figure at the column and then modifiy the data via

BusinessObject row = ((UIElementResponsibleForTeDrop)e.Source).DataContext;
like image 148
Ostas Avatar answered Sep 28 '22 05:09

Ostas