Introduction

Completed

Note

.NET MAUI is the next evolution of Xamarin and what we recommend you develop mobile and desktop apps with, and you can learn more about .NET MAUI in several training modules. This Xamarin training module will not be maintained going forward.

Using the same fonts and colors across your entire UI creates a consistent look and feel. Xamarin.Forms provides a way to define these values in one place and look them up everywhere they're used. Reusing values guarantees consistency across your app and makes updates simple.

Suppose you're building a mobile application called Tip Calculator. The app is used in the hospitality industry and allows attendants to quickly calculate the gratuity for any service. Your company recently changed the look of its corporate brand. Your job is to update the app's UI to match the new look. You'll need to change fonts, text colors, and background colors. You want to make this kind of update easy because there will be more branding changes as your company grows.

Here, you'll see how to define and apply a resource both in code and in XAML. You'll also group multiple settings into a style so you can apply them all at once.

Note

This module requires Visual Studio 2019. You can use either Windows or a Mac:

  • Windows: Make sure you have the Mobile development with .NET workload installed in Visual Studio 2019 for Windows. Refer to the documentation if you need to add it to your installation.
  • macOS: The standard Visual Studio 2019 for Mac installation includes everything you need to build mobile apps with Xamarin.

Learning objectives

In this module, you will:

  • Create a consistent UI by using resources and styles
  • Apply the user's accessibility choices by using built-in styles

Prerequisites

  • Visual Studio 2019 (any edition)
  • Familiarity with C# and .NET