Wpf 在另一个项目中继承自定义UserControl时,为什么会出现XamlParseException?

Wpf 在另一个项目中继承自定义UserControl时,为什么会出现XamlParseException?,wpf,xaml,inheritance,user-controls,Wpf,Xaml,Inheritance,User Controls,在一个项目中,我有一个编辑器类: namespace TestXamlInherit234 { public class CustomerEditor : BaseEditor { public CustomerEditor() { TheMessage.Text = "changed222"; } } } 从另一个项目中的WPF用户控件继承的: using System.Windows.Contr

在一个项目中,我有一个编辑器类:

namespace TestXamlInherit234
{
    public class CustomerEditor : BaseEditor
    {
        public CustomerEditor()
        {
            TheMessage.Text = "changed222";
        }
    }
}
从另一个项目中的WPF用户控件继承的:

using System.Windows.Controls;

namespace Core
{
    public partial class BaseEditor : UserControl
    {
        public TextBlock TheMessage
        {
            get
            {
                return TheMessage2;
            }
        }

        public BaseEditor()
        {
            InitializeComponent();

        }
    }
}


<UserControl x:Class="Core.BaseEditor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <Grid>
        <TextBlock x:Name="TheMessage2" Text="This is in the base editor"/>
    </Grid>
</UserControl>
使用System.Windows.Controls;
名称空间核心
{
公共部分类BaseEditor:UserControl
{
公共文本阻止消息
{
得到
{
返回消息2;
}
}
公共BaseEditor()
{
初始化组件();
}
}
}
当两个类都在同一个项目中时,这是有效的,但当它们在两个不同的项目中时,我会得到一个XamlParseException错误。

尝试:

<Core:BaseEditor x:Class="TestXamlInherit234.CustomerEditor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Core="yourcorenamespace"
    Height="300" Width="300">
    <Grid>
        <TextBlock x:Name="TheMessage2" Text="This is in the base editor"/>
    </Grid>
</Core:BaseEditor>


WPF对继承任何类型的用户控件的支持非常有限。当我这样做是为了解决缺乏泛型支持的问题时,我不得不在代码中定义控件并从ContentControl派生。

我无法让这个建议起作用,我也不明白为什么我要在BaseEditor XAML中定义CustomerEditor类。目前,我们也只是在跨项目边界执行XAML较少的类,但必须有一种方法来实现这一点。