WPF C# Derived UserControl Net Core Namespace Does Not Exist

130 Views Asked by At

I'm trying to migrate a C# WPF application from 4.8 Framework to Net Core 3.1 on VS2019/Windows 11. My build fails :

Error XDG0008 The name "UserControlBase" does not exist in the namespace "clr-namespace:WpfApp2". WpfApp2 \UserControl2.xaml Line 1

My UserControls are derived from a base class that itself is derived from UserControl. E.g.

<local:UserControlBase x:Class="WpfApp2.UserControl2"
             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" 
             xmlns:local="clr-namespace:WpfApp2"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
            
    </Grid>
</local:UserControlBase>

Then the UserControlBase class is like this:

namespace WpfApp2
{
    public class UserControlBase : UserControl
    {
    }
}

My proj file for this demo application is thus:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
</Project>

UserControls declared like "<UserControl x:Class=WpfApp2.UserControl1..." and "public partial class UserControl1 : UserControl..." compile without issue.

Any ideas how to overcome this? My derived usercontrols are done this way to allow them to be used in a factory type way & be created in code behind when needed by the end-user. It's pretty fundamental to the application.

Thanks, Steve

0

There are 0 best solutions below