I wanted to use a common base class for a set of UserControls in my WPF application, but when I changed the class’s ancestor in the code file and compiled I would get the error

“Partial declarations of must not specify different base classes”

This is because when you compile a WPF application Visual Studio generates a partial class in a code-behind file automatically, the base type specified is always “UserControl”.  To solve this problem change your XAML from this

   1:  <UserControl
   2:    x:Class="MyApp.MyControl"
   3:  />

To this

   1:  <local:SomeBaseTypeYouWantToUse
   2:    x:Class="MyApp.MyControl"
   3:    xmlns:local="clr-namespace:NameSpace.To.Your.BaseClass"
   4:  />
Tags
Comments
Write the first comment
Leave a trace
Name *
Email *
Website
Anti SPAM * Code (3 + 3) =
Leave me a comment *
 
All comments are subject to editorial review
Post being viewed right now
Item date: 05.02.2009
Views: 1618
Item date: 19.07.2009
Views: 1859
Item date: 26.09.2009
Views: 2068
Item date: 01.03.2009
Views: 1080
Item date: 02.01.2009
Views: 1883
Item date: 04.02.2009
Views: 876
Item date: 02.01.2009
Views: 1911
Item date: 13.05.2009
Views: 1598
Item date: 01.01.2009
Views: 2011
Item date: 25.09.2009
Views: 964