从桌面拖放c1datagrid中的drop

时间:2015-03-20 09:10:48

标签: xaml datagrid drag-and-drop silverlight-5.0 componentone

我在silverlight 5中有一个应用程序。我在我们的应用程序中使用了c1datagrid。我想将项目从桌面拖放到我们的c1datagrid行,同时我想要突出显示我正在删除的特定行。

2 个答案:

答案 0 :(得分:1)

可以在Silverlight应用程序中拖放。检查"要求提升权限"在silverlight项目属性和使用silverlight datagrid的drop事件中,可以处理从silverlight数据网格中的桌面拖放,前提是它不是OOB silverlight应用程序。

private void DocumentsDrop(object sender, DragEventArgs e)
{
e.Handled = true;

var point = e.GetPosition(null);
var dataGridRow = ExtractDataGridRow(point);
if(dataGridRow !=null)
{.....
 }

var droppedItems = e.Data.GetData(DataFormats.FileDrop) as      FileInfo[];
if (droppedItems != null)
     {
        var droppedDocumentsList = new List<FileInfo>();

        foreach (var droppedItem in droppedItems)
        {
            if ((droppedItem.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
            {
                var directory = new DirectoryInfo(droppedItem.FullName);
                droppedDocumentsList.AddRange(directory.EnumerateFiles("*", SearchOption.AllDirectories));
            }
            else
            {
                droppedDocumentsList.Add(droppedItem);
            }
        }

        if (droppedDocumentsList.Any())
        {
            ProcessFiles(droppedDocumentsList);
        }
        else
        {
            DisplayErrorMessage("The selected folder is empty.");
        }
    }
 }      

设置AllowDrop = true;在xaml中为datagrid。从DragEventArgs中提取信息为FileInfo Object。

答案 1 :(得分:0)

您无法执行从桌面到Silverlight应用程序的拖放操作。这是一个技术限制。