From the course: Microsoft XAML: 3 Type Converters and Resources
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Create a custom markup extension
From the course: Microsoft XAML: 3 Type Converters and Resources
Create a custom markup extension
- [Instructor] To create a custom markup extension, add a class to your project, then derive from markup extension. Give your class a good name, my extension is a random number generator so I decided to call it roll the dice, and I'm using the Microsoft naming convention which is to put the word extension on the end of my class. So the fully qualified name of my class is roll the dice extension. When I use it in my zaml I only need to use this part of the name though, roll the dice. When you use a markup extension in zaml you typically pass one or more parameters into the markup extension, then your code does the work, the custom markup extension does some work and returns a value that's then used as the property value in the zaml. The key to doing that is to override this method, provide value. And this can return anything. This is returned of type object, I'm going to return a string. If you want to specify a particular data type that you return other than object, you come up to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Explore the concepts of type converters5m 26s
-
(Locked)
Use some type converters6m 30s
-
(Locked)
Create a custom type converter8m 24s
-
(Locked)
A markup extension and how it compares to a type converter3m 11s
-
(Locked)
Use some common markup extensions5m 47s
-
(Locked)
Create a custom markup extension3m 29s
-
(Locked)
Add parameters to a custom markup extension4m 34s
-
-
-