Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi again!

I created a usercontrol with a view virtual methods so I could derive from them and use the standard behaviour where needed.
Now XAML tells me
"Error 1 Partial declarations of 'xxx.View.UserControl1' must not specify different base classes ...\View\UserControl1.xaml.cs 20 26"

Isn't it possible to do it this way? I do use interfaces but wanted to have a predifined behaviour which can be overwritten where needed.

Help would be appreciated!
Thank you in advance
Posted

Oh dear - you've hit a fairly common problem here, and it's to do with the way WPF generates a backing class to actually map your controls in (it's called xxxx.g.cs where xxx is your class). You need to do a bit of work to get round this, and here's[^] a link to an entry you might find useful.

 
Share this answer
 
Hello,

The solution is quite easy in fact.

When u derive from usercontrol, you have to do it in the code behind and in the XAML you have to change the tag by the one of your derived class. SO the solution is :
1) Declare the XML namespace of your controls (in the old UserControl tag)
2) Change the "UserControl" tag to the YourXMLNameSpace:YourDerivedControl one

That's all
 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900