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.
Add parameters to a custom markup extension
From the course: Microsoft XAML: 3 Type Converters and Resources
Add parameters to a custom markup extension
- [Lecturer] I'll add some parameters to this mark-up extension by creating another constructor. First thing I need to do is create another field up here. Private, this is going to be a Boolean. This one will be called show dice total. I'll set the default value for this to true. Then I'll modify my code in the provide value section. So I have this list here that I've added, and this will be for storing the individual dice values. So inside my for loop when I generate my random number I'll go to my dice list, and I'll add the role value there. Then down here in this if statement, I'll check this show dice total. If that's true, then I'll return the total, otherwise I'll return a common delimited list of the items that are in this dice list. I'll compile everything, make sure it works. Got no build errors. Now the last thing I need to do is add the constructor, so that I can pass those multiple parameters. So I'll copy this constructor. Now here I'll set my field, show dice total is…
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
-
Use some type converters6m 30s
-
Create a custom type converter8m 24s
-
A markup extension and how it compares to a type converter3m 11s
-
Use some common markup extensions5m 47s
-
Create a custom markup extension3m 29s
-
Add parameters to a custom markup extension4m 34s
-
-
-