From the course: .NET MAUI: Beyond the Basics

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Creating markup extensions

Creating markup extensions - .NET MAUI Tutorial

From the course: .NET MAUI: Beyond the Basics

Creating markup extensions

- [Instructor] Sometimes it can be difficult to do things in XML that would otherwise be straightforward to do in code. One thing that can help us with this is by creating custom XAML markup extensions. Markup extensions allow us to create a bridge between XAML properties and custom code that can do things like load XML files, call into databases, or load images. In this case, if we look at the start code of the project, we can see that we have an XML file called some XML. And if we open it up, it contains a single node that we want to load into a label on our main page, and that note is called my node. We could load the XML into our view model and pass the values over using data binding. However, in this case, we just want to load the XML once and it is strictly display logic that doesn't belong in the view model. So, for this, we'll create a custom markup extension. So, we'll start by creating a folder for our extension.…

Contents