1

I need all my user controls to have some similar functionality. So my user control it is as:

using System.Windows.Controls;


namespace WpfApplication26
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    }
}

ok now I want to make that control inherit from a base class where I have all my functionality as a result I now have something like:

enter image description here

I posted a picture to show you guys the error that I am getting. UserControl1 should be able to inherit from DraggableControl Since DraggableControl inherits from UserControl. I don't understand why visual studio does not let me compile that code.

Tono Nam
  • 34,064
  • 78
  • 298
  • 470
  • Possible duplicate of [How can a WPF UserControl inherit a WPF UserControl?](https://stackoverflow.com/questions/887519/how-can-a-wpf-usercontrol-inherit-a-wpf-usercontrol) – StayOnTarget Sep 05 '18 at 12:18

1 Answers1

5

It's probably because you didn't change the XAML declaration accordingly.

Answers to this question may help.

However, it looks like you can't derive from a class that has XAML :-(

Community
  • 1
  • 1
Serge Wautier
  • 21,494
  • 13
  • 69
  • 110
  • 1
    what will I have to change on the xaml? the x:Class attribute? – Tono Nam Oct 25 '11 at 20:59
  • But nowhere in the XAML one can specify where it inherits from, I guess it assumes UserControl. Here is a good set of options but as far a I know XAML won't play nice with other base classes, there are some options though, take a look at this article http://gen5.info/q/2009/02/10/subverting-xaml-how-to-inherit-from-silverlight-user-controls/ – Ernesto Oct 25 '11 at 21:08