Creating the WalksMainPageViewModel using C#
Now that we have created our BaseViewModel
class which will be used and inherited by each of the ViewModels that we create, the next step is to start creating the WalksMainPageViewModel
class that will be used by our WalksMainPage
.
The WalksMainPageViewModel
ViewModel class will be used to populate our data model and display the information within our ListView
by setting the BindingContext
within the ContentPage.
Let's take a look at how we can achieve this by following these steps:
- Ensure that the
TrackMyWalks
solution is open within the Visual Studio for Mac IDE. - Next, right-click on the
ViewModels
folder and chooseAdd|New File...
from the pop-up menu.
- Then, choose the
Empty Class
option under theGeneral
section and enterWalksMainPageViewModel
for the name of the class to be created, as shown in the following screenshot:

Creating the WalksMainPageViewModel Class
- Next, click on the
New
button to allow the wizard to proceed and create the new file...