12

I had started a question here: WPF drag and drop files onto TreeView from windows explorer but I just discovered this is a totally different problem that what I thought it was.

I have an extremely simple test case.

I was using a treeview but if I use a simple listbox with no code just the following xaml

<StackPanel Orientation="Vertical">
    <ListBox Height="312" Background="#FFBDD6FF" AllowDrop="True"/>
</StackPanel>

If I run the project in expression blend and drag a file over the listbox I see the arrow and the little square below it that incdicates you can drag and drop.

If I run the same project in visual studio and drag a file over the listbox I get a black circle with a line through it.

What could be wrong with my computer or code that is causing that?

Cœur
  • 37,241
  • 25
  • 195
  • 267
249076
  • 650
  • 12
  • 22
  • I just tested your code exactly on my computer and I get the square in Visual Studio. I would apply all services packs and patches and reboot. – paparazzo Sep 20 '11 at 13:39

1 Answers1

26

Is it possible that you are running Visual Studio as Administrator and Expression Blend normally?

Dominik
  • 3,342
  • 1
  • 17
  • 24
  • Yes. Does running as administrator interfere with drag and drop? – 249076 Sep 20 '11 at 13:29
  • 2
    Yes it does, try starting a notepad.exe instance and drag&drop a file from explorer. See that it will open. Now try the same with an instance started as administrator, which will not open the file – Dominik Sep 20 '11 at 13:31
  • That explains all my problems for the last day and a half then. I also found this bug submission on Microsoft Connect: http://connect.microsoft.com/VisualStudio/feedback/details/537964/drag-and-drop-to-open-file-is-not-working-at-all. I guess if notepad has the same behaivior it isn't really a bug. Some kind of security thing I suppose? – 249076 Sep 20 '11 at 13:32
  • 5
    No this is not a bug, elevated (in your case VisualStudio) and non-elevated (in your case Explorer) processes are shielded from direct communication with each other. Welcome to the wonderfull world uf UAC – Dominik Sep 20 '11 at 13:36
  • It is called UIPI, take the first google hit. You can't hijack the privileges of an elevated program with D+D. Makes sense, no workaround. And not a real problem to your user. – Hans Passant Sep 20 '11 at 13:40