This is a migrated thread and some comments may be shown as answers.

Drag from desktop and drop in Silverlight

2 Answers 96 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Niclas
Top achievements
Rank 1
Niclas asked on 16 Dec 2008, 07:06 AM
This is what my customers wants from the application. To be able to drag and drop picture files from other applications, the File Explorer or the Desktop, to the SilverLight application. Is that supported?

2 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 17 Dec 2008, 11:55 AM
Hello Niclas,

Unfortunately this will not be possible, the Silverlight plugin does not yet allow us to interact with the native drag/drop APIs. As stated in the documentation as well:

http://www.telerik.com/help/silverlight/raddraganddropmanager-structure.html

The drag-drop is entirely implemented in Silverlight and does not support cross-application scenarios.

Regards,
Miroslav
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pushpendra
Top achievements
Rank 1
answered on 19 Feb 2016, 10:56 AM

One can Drag and drop in a silverlight application. Check "Require Elevated permissions" in silverlight project properties and using drop event of silverlight datagrid one can handle the drag and drop from desktop in a silverlight datagrid provided its not an OOB silverlight application.

 

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.");

     }

   }

}

Set AllowDrop =true; in xaml for the datagrid. From the DragEventArgs extract the information as FileInfo Object.

Tags
DragAndDrop
Asked by
Niclas
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Pushpendra
Top achievements
Rank 1
Share this question
or