C# 为什么UserControl不可能从UserControl以外的内容继承

C# 为什么UserControl不可能从UserControl以外的内容继承,c#,wpf,inheritance,base-class,C#,Wpf,Inheritance,Base Class,我需要所有的用户控件都具有类似的功能。因此,我的用户控件如下所示: using System.Windows.Controls; namespace WpfApplication26 { /// <summary> /// Interaction logic for UserControl1.xaml /// </summary> public partial class UserControl1 : UserControl {

我需要所有的用户控件都具有类似的功能。因此,我的用户控件如下所示:

using System.Windows.Controls;


namespace WpfApplication26
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    }
}
使用System.Windows.Controls;
命名空间WpfApplication26
{
/// 
///UserControl1.xaml的交互逻辑
/// 
公共部分类UserControl1:UserControl
{
公共用户控制1()
{
初始化组件();
}
}
}
好了,现在我想让该控件从基类继承,在基类中我拥有了所有功能,因此我现在有了如下内容:


我贴了一张照片给你们看我犯的错误。UserControl1应该能够从DragableControl继承,因为DragableControl继承自UserControl。我不明白为什么visual studio不让我编译这些代码。

可能是因为您没有相应地更改XAML声明

答案可能会有所帮助


但是,看起来您无法从具有XAML:-(

的类派生,这可能是因为您没有相应地更改XAML声明

答案可能会有所帮助


但是,您似乎无法从具有XAML的类派生:-(

我必须在xaml上更改什么?x:Class属性?但是在xaml中没有任何地方可以指定它从何处继承,我猜它假定为用户控制。这里有一组很好的选项,但据我所知,xaml不能很好地与其他基类配合使用,尽管有一些选项,看看这篇文章,在这篇文章中我必须更改什么xaml?x:Class属性?但在xaml中,没有任何地方可以指定它从何处继承,我想它假定为UserControl。这里有一组很好的选项,但据我所知,xaml不能很好地处理其他基类,不过有一些选项,请看本文可能重复的可能重复的