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 also highly customizable through styles and the 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 together 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: https://learn.microsoft.com/dotnet/maui/user-interface/graphics/
In this chapter, we’ll look at the first two of these three approaches. We’ll start by building our own control by re-using 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.