XamlParseException when using a page from a library

I recently started work on a project that should target Windows RT (C #). Having some experience working in Silverlight and WPF, I created an assembly (library) that should contain some of my UserControls, Pages, etc. For subsequent reuse.

I added a blank page for this.

Whenever I go to this page (using the navigation mechanisms), the constructor is called correctly, but there is a non-descriptive XamlParseException exception during the call to InitializeComponent ().

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.gics: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 cannot determine the reason for this, so I decided to ask for some recommendations.

Anyone else run into this?

+2
winrt-xaml microsoft-metro xamlparseexception
source share
2 answers

There seems to be a bug in generating code for Win RT. This blog post describes how to work around this issue. Worked for me.

http://blog.excastle.com/2012/09/06/xamlparseexception-in-winrt/

+1
source share

I came across a similar incident using the following script:

1 - Create a project for winRT (solution created)

2 - Add another winRT project to the solution

3 - Create a UserControl in project 2

4 - Drop the control on the page in project 1.

5 - Run the application Get Xaml Parser Error

2 solutions were found that we used for various business tasks:

1 - Copy the controls from project 2 to the main project in the area of ​​subfiles / subfields called controls. When userControls are located in the project that will use them, the problem will not remain.

2 - If you MUST separate the controls in project 2 from project 1, the controls used in the libraries MUST be of the Templated User Control type, and not of the more general User Control type.

I am NOT claiming to know why this happened ... simply that both modifications were acceptable in the eyes of the XAML compiler.

0
source share

All Articles