开发者

WPF drag and drop to DataGrid

开发者 https://www.devze.com 2022-12-24 04:59 出处:网络
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 im

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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号