I've recently started work on a project that is supposed to target Windows RT (C#) Having some background in Silverlight & WPF I've created an assembly (library) that is supposed to hold some of my UserControls, Pages etc. for later re-use.
I've added an empty Page to that assemly.
Whenever I navigate to that page (using navigation mechanisms), the contructor is called correctly, however there's a non-descriptive XamlParseException during the InitializeComponent() call.
Message: XAML parsing failed
InnerException : null
StackTrace: at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
at Project.Modules.ImagesModule.Pages.CameraPage.InitializeComponent() in c:\Users\misztalm\Documents\Visual Studio 2012\Projects\VirtualEye\trunk\Sources\Project.Modules.ImagesModule\obj\Debug\Pages\MyPage.g.i.cs:line 30
at Project.Modules.ImagesModule.Pages.MyPage..ctor() in c:\Users\misztalm\Documents\Visual Studio 2012\Projects\VirtualEye\trunk\Sources\Project.Modules.ImagesModule\Pages\MyPage.xaml.cs:line 20
I'm failing to determine the cause of this, so I've decided to ask for some guidance.
Anyone else run into this?
I ran into a similar incident using the following scenario:
1 - Create a project for winRT (Solution is created)
2 - Add another winRT project to the solution
3 - Create a UserControl in project 2
4 - Drop the Control on a page in Project 1.
5 - Run App Get Xaml Parser Error
There were 2 Solutions to this that we used for different business needs:
1 - Copy the controls from the Project 2 to the main Project in a SubFolder / SubNamespace called Controls. When the userControls are located ion the project that will use them, the issue doe not remain.
2 - If you MUST separate the Controls in Project 2 From Project 1 The Controls being used across libraries MUST be of type Templated User Control as opposed to more generic User Control type.
I do NOT claim to know why this occurred... just that both modifications were acceptable in the eyes of the XAML compiler.
Apparently there's a bug in code generation for Win RT. This blog post describes how to work around the issue. Worked for me.
http://blog.excastle.com/2012/09/06/xamlparseexception-in-winrt/