From the course: Microsoft XAML: 3 Type Converters and Resources
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Create a custom type converter
From the course: Microsoft XAML: 3 Type Converters and Resources
Create a custom type converter
- [Instructor] I'm ready to create a custom type converter to solve this problem. I have this rating control, and if you remember the rating control has a number of properties. They're listed here, and the property that we're concerned about is this StarBorder property. It's of a custom type, I created a type called Borderline, and when I attempt to set the value in my XAML over here, copy this and paste it in here, I get a blue squiggle. When I hover over that it says the TypeConverter for Borderline does not support converting from a string. The actual problem is the Borderline class doesn't even have a TypeConverter, so let's fix that. I'll go over to my rating control, go to it's C# code, and what I did is I created a class in here called Borderline and I also created a class in here called BorderlineConverter, and there's also a class of course my rating control is in here, now normally I would put these classes in separate files, but for this demonstration for simplicity…
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
-
-
-