Friday, April 06, 2012

Partial declarations of must not specify different base classes

I am working on my first WPF application and I decided to clean up my code and moved all common properties into a  base class for all my user controls. I hit this error, Partial declarations of must not specify different base classes. After a few minutes of head scratching, I found this post,
http://blog.peterlesliemorris.com/archive/2009/07/23/partial-declarations-of-must-not-specify-different-base-classes.aspx, by Peter Morris that fixed the problem. Basically, the base class is declared in the xaml.

Basically, just change your xaml from
<UserControl x:Class="MyApp.MyUserControl" />
to
<local:BaseUserControl
  x:Class="MyApp.MyUserControl "
  xmlns:local="clr-namespace:NameSpace.To.Your.BaseClass"
  />

Yes, I copied the sample from Peter Morris's post.

No comments: