Question

I'm working on a Metro app using XAML & C#. I started this using WPF in Win7. I created a base class, inheriting from UserControl, then tried to put that in my XAML.

In Windows 7, this worked great:

<MyType:AnImplementation
 ...
 xmlns:MyType="clr-namespace:MyAppNamespace"
/>

I tried the same thing in Win8, but unfortunately, I get errors -

<MyType:AnImplementation
 ...
 xmlns:MyType="using:MyAppNamespace"
/>

now produces this: CompileXaml task failed unexpectedly. Then a null reference exception.

I'm no WPF whiz, so I may be doing this completely wrong - I just recently started getting into it, but I'm having trouble isolating this issue. Is this some sort of chicken/egg problem, or is there a different way to build custom user controls in Win8 XAML?

edit: I thought it may be helpful to be more clear. I'm not having trouble creating user controls, I'm having trouble creating usercontrols that are of my own base type, which inherits from UserControl. For instance:

A base class, we'll call MyBaseType, which inherits from UserControl and has some virtual methods:

public class MyBaseType : UserControl
{
    public MyBaseType() : base() {}
}

A new usercontrol, called ActionTile:

public partial class ActionTile : MyBaseType {}

When I put this in my XAML:

<myType:MyBaseType
    ... (other XAML imports)
    xmlns:myType="using:MyNamespace"/>

The compiler blows up.

If you want to replicate, create a base class inheriting from UserControl, then implement a control inheriting from the base class and try to create a new UserControl of that new type. As I said, works fine in WPF on Windows 7.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top