Question

I am trying to subclass a UserControl after reading the following: How can a WPF UserControl inherit a WPF UserControl?

But I seem to have missed something.

Base class, which is not partial nor does it have an XAML:

namespace HTTPFreeForm
{
    public class HTTPBaseForm : UserControl, IForm
    /* ... more content ... */
}

Subclass codebehind:

namespace HTTPFreeForm
{
    public partial class HTTPFreeForm : HTTPBaseForm
    /* ... more content ... */
}

Subclass XAML:

<local:HTTPBaseForm x:Class="HTTPFreeForm.HTTPFreeForm" 
             xmlns:local="clr-namespace:HTTPFreeForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <!-- ... more content ... -->
</local:HTTPBaseForm>

When I try to build, I receive the following error:

Error 2 The type name 'HTTPBaseForm' does not exist in the type 'HTTPFreeForm.HTTPFreeForm' c:\MyProject\HTTPFreeForm\obj\Debug\HTTPFreeForm.g.cs 42 54 HTTPFreeForm

What am I missing or doing wrong?

Was it helpful?

Solution

As requested comment to answer.

You have conflict on names your namespace is named the same as class. Change that and try again.

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