0

Possible Duplicate:
Drag and Drop MVVM

I want to open a file when it is dropped on my application. I have found this question which is partly answering it. My problem is that I am using the MVVM pattern and need to call the openFile() method in the command line in the xaml file. Does anyone know how to call the method and add the correct file parameter to it so that i can open the file? I am not sure if I will have to use the command parameter, that is only what i have done in all the other method calls to the ViewModel file.

Here is a little from my XAML code:

<DockPanel 
    AllowDrop="True" 
    Drop="DockPanel_Drop">

Maybe it is possible to call the methods from the ViewModel from my code behind?

Community
  • 1
  • 1
7heViking
  • 7,137
  • 11
  • 50
  • 94
  • 1
    could you rewrite the marked sentence in another way? i dont understand whats your problem – fixagon Dec 02 '11 at 08:04
  • Just edited it a little so you might understand it now – 7heViking Dec 02 '11 at 08:23
  • 1
    There are already dupes of this question on the site. Can't find the best one right now, but voting to close. You can easily find them by searching for "mvvm drag and drop" – Merlyn Morgan-Graham Dec 02 '11 at 08:32
  • Thanks. I found my solution here: [http://stackoverflow.com/questions/5916154/drag-and-drop-mvvm][1] [1]: http://stackoverflow.com/questions/5916154/drag-and-drop-mvvm – 7heViking Dec 02 '11 at 08:41
  • Thanks I found the solution here: [http://stackoverflow.com/questions/5916154/drag-and-drop-mvvm][1] [1]: http://stackoverflow.com/questions/5916154/drag-and-drop-mvvm – 7heViking Dec 02 '11 at 08:42
  • 1
    To use Drag/Drop with MVVM, it is **NOT** recommended to use code-behind to handle the drop event. I recommend reading [this](http://www.codeproject.com/KB/WPF/gong-wpf-dragdrop.aspx) and [this](http://blog.galasoft.ch/archive/2009/12/17/silverlight-4-dragampdrop-with-eventtocommand.aspx). – Jake Berger Dec 02 '11 at 14:59

0 Answers0