Using Arbitrary Types in XAML

Thanks to XAML’s general-purpose nature, you can use it with just about any .NET object, C++/CX objects in a C++ app targeting the Windows Runtime, or even COM objects in a WPF app, thanks to COM interoperability. This includes types you define yourself.

It doesn’t matter whether these objects have anything to do with a user interface. However, the objects need to be designed in a “declarative-friendly” way. For example, if a class doesn’t have a default constructor and doesn’t expose useful instance properties, it’s usually not going to be directly usable from XAML. A lot of care went into the design of the XAML-based frameworks—above and beyond the usual .NET or Windows Runtime design guidelines—in order to fit ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.