views:

395

answers:

2

I'm working on re-writing a WinForms application into Silverlight. One use case in the WinForms app allows users to drag TIFF images (of faxes) from Outlook directly onto an "attach an image or fax to this case" control in the WinForms app. Is there a Silverlight 4 control which allows for the same functionality? It's important to realize that saving the file to the local filesystem and then selecting and uploading the file with a standard upload control will not meet the business requirements as outlined in the project.

A: 

Silverlight 4 does support the dragging and dropping of files from the file system to any UIElement. See this blog

However whether this will work with drags initiatedin Outlook I don't know. I suggest you get the sample from this blog and build a little test app so see if you can drag the attachments.

Of course you've still got the work to decode TIFF into a bitmap that Silverlight can use.

AnthonyWJones
A: 

(My guess is that Silverlight will be a tough port for much of the functionality due to it's 'lightweight' nature. You may want to consider using a Click-once WPF application instead of Silverlight, especially since you're already relying on a rich installed Windows application).

You'll need to do something like this in the constructor for your Silverlight user control,

this.Drop += new DragEventHandler(MainPage_Drop);

Then add a method

void MainPage_Drop(object sender, DragEventArgs e)
{
    IDataObject drop = e.Data;

    if (drop.GetDataPresent(System.Windows.DataFormats.FileDrop))
    {
        FileInfo[] files = (FileInfo[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
        foreach (FileInfo file in files)
        {
          // do something with each file here
        }
    }
}

Then -- see what happens. You'll need to use a library for adding TIFF support possibly something like suggested on Stackoverflow, here.

WPCoder