I\'m trying to get a grasp on WPF and MVVM and have been making good progress. The WPF and MVVM side of things are going well.
However, the XAML and data binding sid
By way of using the command pattern. In your view model:
public class MyViewModel : ViewModel
{
private readonly ICommand someCommand;
public MyViewModel()
{
this.someCommand = new DelegateCommand(this.DoSomething, this.CanDoSomething);
}
public ICommand SomeCommand
{
get { return this.someCommand; }
}
private void DoSomething(object state)
{
// do something here
}
private bool CanDoSomething(object state)
{
// return true/false here is enabled/disable button
}
}
In your XAML:
Read this post to find out more about the DelegateCommand
.