Support forum
wyDay blog
wyDay Home

The wyDay blog is where you find all the latest news and tips about our existing products and new products to come.

wyDay blog

October 19th, 2009

In today’s tip I’m going to cover showing drag & drop icons. Specifically keeping the icon overlay shown when you drag files from Windows Explorer to your .NET application. Here’s a close-up of a user dragging files from a folder into wyBuild.

If we had used the normal .NET Framework interfaces for dragging files to wyBuild as soon as the cursor passes into the window the icons would disappear.

But, as you can see in the screenshot, the icons stay when dragging over our window. We can also set the drag & drop text to the current folder the user is dragging over.

How to add this to your app

This is one control I can’t take credit for. Adam Root from Microsoft wrote up a nice control on his blog in a post Shell Style Drag and Drop in .NET – Part 3. The control works for both Windows Form and Windows Presentation Foundation (WPF) applications.

He wrote a 3 part series, and it’s interesting if you want to dig into the nitty-gritty Windows API.

How we use Drag & Drop in wyBuild

We use the Windows Form control in wyBuild, but we have to use a little trickery to get it work right. Because Adam wrote the Drag & Drop control using a .NET Framework 3.5 language feature, and wyBuild is built using .NET Framework 2.0, we have to use this little trick from Daniel Moth.

Just add this snippet of code to your project and you’ll be all set to go.

//HACK: this is to support a .NET language 3.5 feature in .NET 2.0
namespace System.Runtime.CompilerServices
    public class ExtensionAttribute : Attribute { }

7 Days of Windows 7

Join me tomorrow when I talk about Using shield icons, UAC, and process elevation. See the full list of articles in the series.

Subscribe to our blog's RSS Feed or follow @wyDay on Twitter to keep up-to-date with our latest posts.