From the course: .NET MAUI: Beyond the Basics
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Specifying generics in XAML - .NET MAUI Tutorial
From the course: .NET MAUI: Beyond the Basics
Specifying generics in XAML
- [Instructor] One thing we may want to do is create a generic View or Page. For example, perhaps you want to create a generic BasePage where the BasePage has a ViewModel property and the generic specifies the type of the ViewModel. This is easy enough to do in code, but how do we do it in XML? Let's start with the project from the starting code for this video. Here we have a BaseViewModel type, right under here, and then a MainViewModel that inherits from it. We want to create a BaseView type that uses a generic to specify that type of the ViewModel. So we're going to go into start with, and right-click on the project, and go in and add, and we're going to add a new item, and we're going to search for a page, and we want to do the .NET MAUI ContentPage. And we'll take the generic C sharp one, or the normal C sharp one, and we'll call this BasePage. Just like that, and add it in. And in this BasePage, we can get rid of the…
Contents
-
-
-
-
-
(Locked)
Referencing custom views4m 17s
-
(Locked)
Constructors and factories4m 4s
-
(Locked)
Specifying generics in XAML7m 25s
-
(Locked)
Creating markup extensions10m 33s
-
(Locked)
Custom view states10m 56s
-
(Locked)
Challenge: Creating a XAML form2m 12s
-
(Locked)
Solution: Creating a XAML form3m 24s
-
(Locked)
-
-
-