You can set up the datacontext in your View with <Grid DataContext = "{Binding}">
You have 1 viewmodel per view but you can have many bound commands! I suggest you look up Josh Smiths RelayCommand as this make this so much easier! A guide is here:
Create a new class
class RelayCommand : ICommand
{
private Action<object> _action;
public RelayCommand(Action<object> action)
{
_action = action;
}
#region ICommand Members
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
_action(parameter);
}
#endregion
}
And in your ViewModel
public ICommand BrowseCommand {get; set;}
public ICommand SearchCommand {get; set;}
public ExampleViewModel()
{
this.BrowseCommand = new RelayCommand(new action<object>(MethodNameEnteredHere);
this.SearchCommand = new RelayCommand(new action<object>(OtherMethodNameEnteredHere);
}
So, your xaml would be
<Grid DataContext = "{Binding}">
<Button Content="Browse" Command="{Binding BrowseCommand}"/>
<Button Content="Search" Command="{Binding SearchCommand}" />
</Grid>