Sending text messages is also very straightforward. We need to create a command that we can bind for the GUI. The command will be executed either when the user hits return or when the user clicks the send button. When a user does either of these two things, the command will create a new SimpleTextMessage and pass in the current user to identify the message for other users. We will use the text from the ChatViewModel text property, which, in turn, is bound to the Entry control.
We will then add the message to the Messages collection, triggering ListView, which will be handling messages that need to be updated. After that, we will pass the message to ChatService and clear the ChatViewModel text property. By doing this, we notify the GUI that it has changed and let the data binding magic clear the field.
Refer to the following steps and look at the code to get to grips with it:
- Create a new property called Send of the ICommand type.
- Assign it a new...