A day in the life...

public class GeekEarth : Earth { }
posts - 14, comments - 22, trackbacks - 0

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

   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:  />

Print | posted on Thursday, July 23, 2009 12:08 PM | Filed Under [ Code ]

Feedback

Gravatar

# re: Partial declarations of must not specify different base classes

helpful
10/1/2009 10:22 AM | maarten de rijk
Gravatar

# re: Partial declarations of must not specify different base classes

Very helpful..
11/10/2009 6:01 AM | Tushar Agarwal
Gravatar

# re: Partial declarations of must not specify different base classes

This is very helpful. Thanks a lot!!
2/10/2010 6:38 PM | Samir Adhikari
Gravatar

# re: Partial declarations of must not specify different base classes

Exactely what I was looking for, thanks.
5/5/2010 10:58 AM | Sdry
Gravatar

# re: Partial declarations of must not specify different base classes

Helpful infi ... thanx
5/10/2010 1:09 PM | twilight
Gravatar

# re: Partial declarations of must not specify different base classes

hu hu , thank u very ^ 10 much !!!!!
5/31/2010 4:21 PM | Nghia
Gravatar

# re: Partial declarations of must not specify different base classes

Great. It was very helpful. I spent a few hours on this and was finally frustated. But your post helped me to resolve my issue. Thanks again.
6/3/2010 8:25 PM | Preeti

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 6 and 3 and type the answer here:

Powered by: