Partial declarations of must not specify different base classes
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
<UserControl
x:Class="MyApp.MyControl"
/>
To this
<local:SomeBaseTypeYouWantToUse
x:Class="MyApp.MyControl"
xmlns:local="clr-namespace:NameSpace.To.Your.BaseClass"
/>
Comments