Note to self - mapping of external namespaces into XAML files changed
I stumbled upon this yesterday. If an external class needs to be referenced in a XAML file, a namespace must be mapped for it, so the compiler knows where to find that class. For example, I had a DataTemplate for a specific type in my file:
Now, the class Klasse is part of a certain namespace (Sturm.MyNamespace), in a certain assembly (Sturm.MyDataAssembly.dll), and in the many references I was able to find, it said I should have something like this in my XAML file for the mapping of the “arbitraryName” namespace:
The problem was that this didn’t seem to work for me – I got errors all the time saying the type “arbitraryName:Klasse” couldn’t be cast to a Type object. Finally I found the solution somewhere: Microsoft changed the syntax of this, a few months back apparently, but obviously not long enough ago judging from the number of web pages giving the old syntax. The new format doesn’t need (and actually doesn’t seem to make any use of) the Mapping instruction, and the xmlns entry has to look like this:





