Follow these simple steps to register the routed command to the button click and perform the operation:
- From the Solution Explorer, right-click on the project node and create a folder named Commands.
- Right-click on the Commands folder and create a new class named RoutedCommands.cs by following the Add | Class... context menu path.
- Inside the class implementation, declare a static member of type RoutedCommand and name it AddCommand. Here's the code implementation:
public class RoutedCommands { public static RoutedCommand AddCommand = new RoutedCommand(); }
- Add the following namespace to resolve the RoutedCommand class:
using System.Windows.Input;
- Once that has been done, navigate to the MainWindowViewModel.cs file, present under the ViewModels folder, and add a property named NewUserDetails of type UserModel. We will be using this property to bind with the Text property of the TextBox controls present in the UI. The property...