Creating the TrackMyWalks model

In this section, we will proceed to create our TrackMyWalks model that will represent our walk entries. As we progress throughout this chapter, we will see how we can use this model to set up and initialize some walk entries for our main WalksPage using a ListView control so that we can display walk entry for each row within the ListView.

Let's take a look at how we can achieve this, by following the steps below:

  1. Create a new folder within the TrackMyWalks Portable Class Library project solution, called Models as shown in the following screenshot:

    Creating the TrackMyWalks model

  2. Next, create a new class file within the Models folder, as shown in the following screenshot:

    Creating the TrackMyWalks model

  3. Then, choose the Empty Class option under the General section and enter in WalkEntries for the name of the new class file to be created as shown in the following screenshot:

    Creating the TrackMyWalks model

  4. Next, click on the New button to allow the wizard to proceed and create the new file, as shown in the preceding screenshot.

    Congratulations, you have created your first folder and C# class file for our solution. We can now proceed with adding the property descriptors that will be used to define our model.

  5. Ensure that the WalkEntries.cs file is displayed, then locate the WalkEntries class constructor and enter the following highlighted code sections:
        // 
        //  WalkEntries.cs 
        //  TrackMyWalks 
        // 
        //  Created by Steven F. Daniel on 04/08/2016. 
        //  Copyright © 2016 GENIESOFT STUDIOS. All rights reserved. 
        // 
 
        namespace TrackMyWalks.Models 
        { 
            public class WalkEntries 
            { 
                public string Title { get; set; }
  
                public string Notes { get; set; }
  
                public double Longitude { get; set; }
   
                public double Latitude { get; set; }
    
                public double Kilometers { get; set; }
    
                public string Difficulty { get; set; }
   
                public double Distance { get; set; }
 
                public string ImageUrl { get; set; } 
            } 
         } 

In the preceding code snippet, we have successfully defined the model that will be used to represent our walk entries. In the next section, we will use this model to set up and initialize some walk entries for our main WalksPage using a ListView control, then use a DataTemplate to describe how the model data should be displayed for each row within the ListView.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.120.136