在WPF中的网格控件内拖放 [英] Drag and Drop within grid control in wpf

查看:112
本文介绍了在WPF中的网格控件内拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我有一个带有四列四行的网格控件.每个单元格都有一张图片,而下面的文字则类似于iPhone图标.该网格在运行时动态填充控件.现在,我需要对其执行拖放操作.但是我不知道我该怎么做.我在google上出现了很多答案,并且只具有Itemscontrol,Datagrid,Listbox拖放.网格中没有答案.谁能为我说出适当的答案.

HI

I have one grid control with four columns and four rows. Each cells are having one image and below one text as like as IPhone icons. This grid fill up the controls dynamically at run time. Now i need to perform drag and drop operation on it. But i dont know how do i perform it. I arised on google with lot of answers and there were having only Itemscontrol,Datagrid,Listbox drag and drop only. No answers in grid. Can anyone say the appropriate answer for me. Please i need this.

推荐答案

您将需要在视图中实现自定义拖放. 此处 [使用MVVM通过拖放在WPF工具包DataGrid中合并两行 [ ^ ]是使用这些结构的示例.
You will need to implement custom dragdrop in your views. Here[^] is some information on this.

Merge Two Rows by Drag and Drop in a WPF Toolkit DataGrid Using MVVM[^] is a sample for using these constructs.


如果您对WPF拖放有所了解,可以找到一种方法.

拖放概述 [
If you read up on WPF drag and drop you can come up with a way to do it.

Drag and Drop Overview[^]

A few possible ways off the top of my head...

1) Use the grid as both a drag source and drop target. The grid handles all movement of its child elements
2) Make the child elements drag sources and drop targets. They''d need to be able to notify the grid of movement
3) Make the child elements drag sources and make the grid a drop target.

The third one is probably easiest to implement. The grid''s row and column definitions can be used to find the cell dropped into.


这篇关于在WPF中的网格控件内拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆