You need to provide a custom ParserContext
to the XamlReader.Parse
method. You should assign the ParserContext.XamlTypeMapper
property to enable XamlParser
to locate the types referenced in your XAML. Something along these lines:
var context = new ParserContext();
context.XamlTypeMapper = new XamlTypeMapper(
new[] {
Assembly.GetExecutingAssembly().GetName().Name,
"Assembly1",
"Assembly2",
"Assembly3",
"Assembly4",
}
);
var element = (FrameworkElement) XamlReader.Parse(xaml, context);