I know this is an old question, but I think the βcorrectβ answer is still missing. You can avoid changing the XAML by adding the required namespaces to the code:
ParserContext context = new ParserContext(); context.XmlnsDictionary.Add("","http://schemas.microsoft.com/winfx/2006/xaml/presentation"); context.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
source share