
Hi
I try to enable file dropping on syntax editor WPF. I set AllowDrop=true and use the event PasteDropEvent:
private void editor_PasteDragDrop(object sender, PasteDragDropEventArgs e)
{
if (e.Action == PasteDragDropAction.DragEnter)
e.DragEventArgs.Effects = DragDropEffects.Copy;
else if (e.Action == PasteDragDropAction.DragDrop && e.DataStore.GetDataPresent(DataFormats.FileDrop))
{
string[] files = e.DataStore.GetData(DataFormats.FileDrop) as string[];
if (files != null && files.Length > 0)
{
using (FileStream stream = File.OpenRead(files[0]))
{
e.Text = new StreamReader(stream).ReadToEnd();
}
}
}
}
It seems not to work in this way. I get the DragEnter event but no DragDrop. Similar code worked with the WinForms Syntax Editor. How can I implement this with WPF Syntax Editor?
Thanks in advance.
Martin