O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom Type Converters

You cannot create your own type converters, unless you’re working in the context of WPF/Silverlight on the desktop. WPF exposes type converters as classes deriving from TypeConverter (BrushConverter, ColorConverter, and so on). To write your own, you create your own TypeConverter subclass. However, your type converter can only be used on properties marked with a TypeConverterAttribute custom attribute that points to your TypeConverter subclass. Or, if the source type you’re converting is one you created, you can mark that type with TypeConverterAttribute so it automatically applies to all properties of that type. The WPF XAML parser looks in both places to find the converter that it needs to invoke.

For example, the BrushConverter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required