We now have a service that is responsible for handling communication with the backend. Now, it's time to create a ViewModel. First, however, we will create a base view model, where we can put the code that will be shared between all the view models of the app:
- Create a new folder called ViewModels.
- Create a new class called ViewModel.
- Make the new class public and abstract.
- Add a static field called Navigation of the INavigation type. This will be used to store a reference to the navigation services provided by Xamarin.Forms.
- Add a static field called User of the string type. The field will be used when connecting to the chat service so that messages you send will be displayed with your name attached.
- Add and implement the INotifiedPropertyChanged interface. This is necessary because we want to use data bindings.
- Add a Set method. This will make it easier for us to raise the ...