ChatViewModel is a simple class that inherits from the ViewModel base class we created earlier. In the first code exercise, we will create the class, adding relevant using statements and a property called Messages, which we will use to store the messages that we have received. The view will use the Message collection to display the messages in a ListView.
Since this is a large block of code, we recommend that you write it first and then go over the numbered list to get to grips with what has been added to the class:
- Create a new class called ChatViewModel in the ViewModels folder of the Chat project.
- Make the class public and inherit it from the ViewModel base class to gain the common base functionality from the base class.
- Add a readonly property called chatService of the IChatService type. This will store a reference to an object that implements IChatService and make the concrete implementation of ChatService replaceable. It's good practice to expose any service...