OK, I tend to avoid using commands because they always manage to confuse the hell out of me, but I'm on a new project and am trying to architect it correctly with no code behind on my view. Basically All I am trying to do right now is wire up a button that fires a command that does some things on my view model, and somehow something so simple is still giving me trouble. I think I'm close but can't quite get there. Here is what I have right now.
<Window.Resources>
<RoutedUICommand x:Key="GetMusic" />
</Window.Resources>
<Window.DataContext>
<core:ViewMain />
</Window.DataContext>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource GetMusic}" Executed="GetMusicExecuted"/>
</Window.CommandBindings>
And the view model is pretty much nothing right now
public class ViewMain
{
public MusicCollection Music { get; set; }
private void GetMusicExecuted(object sender, ExecutedRoutedEventArgs e)
{
//Logic
}
}
Now what I'm trying to do is wire up this command I set up in my command bindings to just call my executed method in my view model, however it tries to find that method within view itself. Is there a way I can direct it to the method in my view model instead, or a better way to set this up to accomplish the same thing? Hoping to keep it simple at first so I don't blow my mind too early.