By Denisse Zavala
Silverlight implementation is one of the services we promote as a nearshore software development firm.
Silverlight 4 includes a new feature that allows developers build rich applications easier and faster without using third party controls.
One interesting feature is the Drag and Drop functionality. Through the following lines I will show how to implement this functionality, dragging files from the desktop right into the Silverlight application.
1. Add a stack panel where the files will be dropped:

Pay attention to the highlighted StackPanel attributes:
a. AllowDrop is used to determine whether the control can be a drop target.
b. Drop is used to specify the Drop Event Handler.
2. Let’s add a ListBox to display each of the files that have been dropped into the drop box:

3. On the code behind we handle the drop event.
First let’s create an observable collection and then bind it to the ListBox we created earlier:

The DroppedFile class needs to implement the INotifyPropertyChanged interface in order to allow the ListBox to display the dropped files as soon as the user drops them into the box:

4. Now, the Drop Event Handler:


The result:

This application only lists the names of the dropped files, furthermore we can extend the functionality to upload the dropped files, display the content of each file and much more complex applications and we can forget about the old and boring browse file dialog box.