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

Referencing .NET/WinRT Namespaces in XAML

Chapter 1 explained that the mapping between XAML namespaces in a XAML file and the .NET or WinRT namespace housing each type is hardcoded into the respective frameworks. So how can you reference arbitrary types from XAML that reside in different namespaces (and assemblies)?

The key is a special directive that enables you to directly use a .NET or WinRT namespace as an XML namespace. Unfortunately, the directive is different for apps that run on the desktop .NET Framework (WPF, WCF, and WF) versus all the other apps.

clr-namespace

For desktop apps, you use a clr-namespace directive. For example, here’s some plain old C# code using .NET Framework APIs contained in mscorlib.dll:

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