11 Beyond the basics: Custom controls

 

This chapter covers

  • Building reusable components with templated controls
  • Creating your own bindable properties
  • Modifying the default controls with handlers
  • A recap on code sharing

.NET MAUI comes with enough controls to let you build almost any UI. Functionally, there is very little that you can’t do using just the standard controls, and they are highly customizable through styles and various styling properties. But, sometimes, you need to go a little further.

In .NET MAUI you have a few ways to build or customize controls, from bundling controls into a reusable component, to customizing the platform implementations that come in the box, to drawing your own controls and graphics with the Microsoft.Maui.Graphics library.

NOTE

Microsoft.Maui.Graphics is a powerful library capable of sophisticated image generation and manipulation. Drawing your own controls is only a small subset of what it’s capable of. If you’re interested in learning more, see http://mng.bz/9D8o.

In this chapter, we’ll look at the first two of these three approaches. We’ll start by building our own control by reusing the built-in controls, and we’ll also see how we can modify the way that .NET MAUI displays the built-in controls by default.

11.1 Using ContentView

 
 
 

11.1.1 Building the custom stepper layout

 
 
 

11.1.2 Improving the custom stepper’s UX

 
 

11.2 Bindable properties

 
 
 

11.2.1 Adding the Value property

 

11.2.2 Adding the IsEnabled property

 
 
 
 

11.3 Modifying platform controls with handlers

 
 
 

11.3.1 Handler architecture

 
 

11.3.2 Overriding handler mappings

 

11.3.3 Implementing custom handler logic

 
 

11.3.4 Updating the custom stepper

 
 
 

11.4 Creating and sharing control libraries

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest