Implementing the LabelShadowEffect RoutingEffect class

In this section, we will begin creating the LabelShadowEffect class for the shared project section of our TrackMyWalks solution. This class will essentially contain a routing reference to our platform-specific class used by our LabelShadowEffect class. Since we cannot directly reference PlatformEffects classes that have been created for each platform, we will need to create a RoutingEffect class, referencing the same name as we defined in each platform, so that it will make it much easier to access these in our XAML pages that utilize this effect.

Let's start by creating the LabelShadowEffect RoutingEffect class for our TrackMyWalks app by performing the following the steps:

  1. Ensure that the TrackMyWalks solution is open in the Visual Studio for Mac IDE.
  2. In the TrackMyWalks project, right-click on the CustomEffects folder and choose Add | New File... from the pop-up menu.
  3. Create a new Empty Class called LabelShadowEffect in the CustomEffects folder, as you did in the section entitled Implementing the ButtonShadowEffect RoutingEffect Class in this chapter.
  4. Ensure that the LabelShadowEffect.cs file, which is located as part of the TrackMyWalks group, is displayed in the code editor and enter the following code snippet:
     //
// LabelShadowEffect.cs
// Creates a Label Shadow Effect using the
// RoutingEffect Class
//
// Created by Steven F. Daniel on 16/07/2018.
// Copyright © 2018 GENIESOFT STUDIOS. All rights reserved.
//
using Xamarin.Forms;

namespace TrackMyWalks.CustomEffects
{
public class LabelShadowEffect : RoutingEffect
{
public LabelShadowEffect() :
base("GeniesoftStudios.LabelShadowEffect")
{
}
}
}

Let's now take a look at what we covered in the preceding code snippet:

  1. We started by including references to the Xamarin.Forms namespace, so that we can access the classes that are defined there
  2. We ensured that our LabelShadowEffect class inherits from the RoutingEffect class, so that we can access each of the platform-specific method implementations of the PlatFormEffect class
  1. We created the LabelShadowEffect class constructor, and ensured that this inherits from the base class that points to the ResolutionGroupName and PlatformEffect assembly attributes in our platform-specific LabelShadowEffect class, so that we can reference this in our XAML pages
..................Content has been hidden....................

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