Creating custom type instances in XAML
Sometimes there's a need to create instances of your own types, or other .NET Framework, non-WPF types within XAML. A classic example is a data binding value converter (which we'll explore in Chapter 6, Data Binding, but other scenarios might call for it).
Make sure you have Visual Studio 2010 up and running.
How to do it...
We'll create a simple application that creates an instance of a custom type in XAML to demonstrate the entire procedure:
- Create a new WPF Application project named CH01.CustomTypes.
- Let's create a custom type named
Book. In the Solution Explorer window, right-click on the project node and select Add and then Class…:
Bookin the Name box and click on Add:
- Add four simple properties ...