简体   繁体   中英

Windows Universal App UI Library Parser internal error

I built a user control in an user control library and I want to include it into my windows universal app. I remember in the old days you had to add something to app.xaml (something like pack:// this is my xaml).

So my thoughts (or hope) I just include my library and user the control. When I do I get - Parser internal error: Object writer 'xClassNotDerivedFromElement'.

I tried adding it as a msappx reference in the App.Xaml, but I may have the syntax wrong. If I can get this working by literally copying over the code itself into my project (which I do not want to do). Suggestions? Thanks

EDIT: Added source code

public MainPage()
{
    _webControl = new NativeWebView.WebUserControl();
    _webControl.Loaded += _webControl_Loaded;
    _contentView = new NativeWebView.ContentView(_webControl);
    this.InitializeComponent();
    root.Children.Add(_webControl);
}


public sealed partial class WebUserControl : UserControl, IWebView
{
    public WebUserControl()
    {
        this.InitializeComponent();
    }

}

So, I found out the answer. So to include a library into another project, you have to have some extra crazy files (.xr.xml and .xrc). I manually copied them into a folder, but it seems they can get out of date. I found that if I want to include the library from the build directory, I have to check a box in the build properties page (Generate library layout). This copies the files for me. SOLUTION!

Just add namespace of the library into root tag of the page where you use the control, ex. for ImageButton control in WinRT XAML Toolkit:

<Page
[...]
xmlns:toolkit="using:WinRTXamlToolkit.Controls">

[...]

<toolkit:ImageButton [...] />

[...]

If you still get xClassNotDerivedFromElement, it means there's a problem in the library. (need source to track it)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM