Attached Properties
Learn how to work with attached properties in .NET MAUI.
Attached properties in .NET MAUI are used to apply additional properties to the elements that haven't been defined by their own classes. These property types allow us to extend the functionality of the elements without having to modify them.
To examine how attached properties work, we'll use the project setup below:
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#512BD4</color> <color name="colorPrimaryDark">#2B0B98</color> <color name="colorAccent">#2B0B98</color> </resources>
.NET MAUI project example with built-in attached properties demonstrated
Attached properties basics
In XAML, attached properties are represented by complex attributes that have sub-attributes. In the setup above, we have some examples of these in the MainPage.xaml
...