ModuleCatalog.CreateFromXaml() in WPF

Topics: Prism v2 - WPF 3.5
Feb 12, 2010 at 8:17 PM

Hi, is it possible to load module configuration from XAML in WPF?

I have no problems in Silverlight but when I'm using the following code in WPF:

 

        protected override IModuleCatalog GetModuleCatalog()
        {
            return ModuleCatalog.CreateFromXaml(new Uri(
                "/ICAP.Client;component/ModuleCatalog.xaml",
                UriKind.Relative));
        }

I'm getting XamlParseException of "' ', hexadecimal value 0x0C, is an invalid character. Line 1, position 1."

I presume this is because ModuleCatalog.xaml is actually precompiled to BAML. Anyone successfully accomplished this?

Thanks,
Eugene 

 

Feb 16, 2010 at 12:40 PM

Hi Eugene,

This is possible and some time ago I created a blog post about how to get this done. Unfortunately, the blog post does not provide any source code but it does point to the main differences between the WPF and Silverlight approach. One other thing to take into account is making sure that the ModulesCatalog.xaml has the BuildAction = Resource setting.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

Feb 11, 2011 at 6:00 AM

Thanks, this is helpful !

Jan 30, 2014 at 5:39 PM
For anyone else experiencing this problem.

It is caused by UTF-8 files that have been saved with a byte order mark (BOM). If you open the xaml file in a good text editor (Notepad++ / Sublime Text) then you should be able to change the encoding or save as a UTF-8 without BOM.