In WPF if we are implementing MVVM pattern then we need to play with Command rather than Events. You can use ICommand interface to create each command class. Implementation of ICommand in a class gives you CanExecute(), Execute() methods which take part in the action performed by Command. Rather than making Command Class for each Command we can implement a generic Relay Command to get Command. Below is a RelayCommand class that we will implement. /// <summary> /// To register commands in MMVM pattern /// </summary> class RelayCommands : ICommand { readonly Action < object > _execute; readonly Predicate < object > _canExecute; ...
Technical Solutions for C, C++, Objective-C, C#, OOP's, Data Structure, Algorithms, Mobile Technology, Mobile Design, HTML/HTML5, Web, iOS/iPad/iPhone, Apple Script, Shell Script, Phonegap, AppAccelerator, Unix, Linux, Mac-OS X, Windows, SQL-Server, PL-SQL, Sqlite3, Database Design issues tips, tricks and hacks by Vinay Mishra.