Donnerstag, 22. August 2013

wpf mvvm? drag and drop? easy? fast result?

This is not a 100% wpf mvvm approach, because this solution will use the help of the default code behind file. As we know, we should avoid touching the code behind file in case of a clean mvvm. Calling a ViewModel-method through the drop event of the default code behind file....

in the code behind file:

using MyProject.MyViewModels;

private void UserControl_Drop(object sender, DragEventArgs e)
      (this.DataContext as UserControlVieModel).OnDrop(sender, e);

in the ViewModel:

public void OnDrop(object sender, System.Windows.DragEventArgs e)
            ExampleText= "dropped";

Benefit from the best Windows Desktop app in the world and use Strokey.Net!

Keine Kommentare:

Kommentar veröffentlichen