Sunday, February 26, 2012

WPF MVVM RelayCommand - Lambda expression for Execute

Like this: // Get ViewModel - provided it is set on init or in XAML MainWindowViewModel viewModel= (this.DataContext as MainWindowViewModel); // aboutCommand lives in ViewModel viewModel.AboutCommand = new RelayCommand( () => { About p=new About(); p.ShowDialog(); } );

No comments: