UserControl InheritanceHi,<br><br>I have two UserControls<br>1.UserControl1<br>2.UserControl2<br><br>how to inherit Usercontrol1 in UserControl2.<br><br>Please give me some idea about this.<br><br>Regards,<br>Vijay<br>© 2009 Microsoft Corporation. All rights reserved.Sat, 12 Sep 2009 10:29:01 Z80eb3f57-9907-4bf7-9f48-b75043b8c97bhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#80eb3f57-9907-4bf7-9f48-b75043b8c97bhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#80eb3f57-9907-4bf7-9f48-b75043b8c97bVijay.Greypadhttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijay.GreypadUserControl InheritanceHi,<br><br>I have two UserControls<br>1.UserControl1<br>2.UserControl2<br><br>how to inherit Usercontrol1 in UserControl2.<br><br>Please give me some idea about this.<br><br>Regards,<br>Vijay<br>Wed, 26 Mar 2008 11:36:31 Z2008-04-01T09:36:38Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#e9f8bd61-2d35-4c8d-86a5-8d4b0d3204fahttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#e9f8bd61-2d35-4c8d-86a5-8d4b0d3204faDenis Vuykahttp://social.msdn.microsoft.com/Profile/en-US/?user=Denis%20VuykaUserControl Inheritance<p>public class UserControl2 : UserControl1</p> <p align=left>{</p> <p align=left>}</p> <p align=left> </p> <p align=left>I think this question is more related to the basics of object oriented programming and you should really refer to the appropriate forums or you simply didn't cover your issue within the question.</p> <p align=left><font face=Arial size=2></font> </p>Wed, 26 Mar 2008 16:16:04 Z2008-03-26T16:16:04Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#a64714af-b7c2-4c26-9d3a-3ecb280251c9http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#a64714af-b7c2-4c26-9d3a-3ecb280251c9Vijay.Greypadhttp://social.msdn.microsoft.com/Profile/en-US/?user=Vijay.GreypadUserControl InheritanceHi Desnis Vuyka,<br><br>You are correct.In CS file you will do like this.<br><span><span id="_ctl0_MainContent__ctl0_PostForm_ReplyBody"> <p>public class UserControl2 : UserControl1</p> <p align=left>{</p> <p align=left>}</p> <p align=left>But what about in Xaml.I did like this</p>In UserControl1.Xaml<br>&lt;UserControl x:Class=&quot;MDIWindows.Parent&quot;<br>    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br>    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;<br>    Height=&quot;300&quot; Width=&quot;300&quot;&gt;<br><br>&lt;/UserControl&gt;<br><br>In UserControl2.Xaml<br>&lt;srcUserControl1 x:Class=&quot;MDIWindows.Child&quot;<br>    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br>    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; xmlns<img alt="Tongue Tied" src="http://forums.microsoft.com/MSDN/emoticons/emotion-7.gif">rc=&quot;clr-namespace:MDIWindows&quot;<br>    Height=&quot;300&quot; Width=&quot;300&quot;&gt;<br>  <br>&lt;/src:UserControl1&gt;<br><br>Here i am getting error.<br>Please me about this.<br> <p align=left><br></p> <p align=left>Regards.<br></p></span></span><br>Thu, 27 Mar 2008 04:18:21 Z2008-03-27T04:18:21Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#ee54548d-fdf9-4823-8978-18a095af1138http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#ee54548d-fdf9-4823-8978-18a095af1138Marco Zhouhttp://social.msdn.microsoft.com/Profile/en-US/?user=Marco%20ZhouUserControl Inheritance<font size=2><span style="font-family:Verdana">In current version of WPF, you cannot subclass from XAML generated classes, you need to do it in code instead something like the following should work:</span></font><br><br> <div style="text-align:left"> <div class=codeseg> <div class=codecontent> <div class=codesniptitle style="font-family:Verdana"><font size=2><span style="width:100%">Code Snippet</span></font></div> <p style="font-family:Verdana">public class Parent : UserControl<br>{<br>}<br><br>&lt;src:Parent x:Class=&quot;Test.Child&quot; <br>                 xmlns:src=&quot;clr-namespace:Test&quot;<br>                 xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br>                 xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;/&gt;</p></div></div><br></div>Hope this helpsFri, 28 Mar 2008 02:30:13 Z2008-04-01T09:36:38Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#b4d3df47-43f3-45f4-aaf9-9ee57717e405http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#b4d3df47-43f3-45f4-aaf9-9ee57717e405bootishttp://social.msdn.microsoft.com/Profile/en-US/?user=bootisUserControl Inheritance<font size=2><span style="font-family:Arial">Dear all,<br><br>I have a question about all this: how to develop my controls for the moment ?<br><br>As inheritance with XAML generated classes does not work, i don't know whether I should </span></font><font size=2><span style="font-family:Arial">programmatically </span></font><font size=2><span style="font-family:Arial">declare all my &quot;generic&quot; controls in the base class, or abandon this idea of common controls and duplicate XAML declarations...<br><br>Actually the question could be: should I design my controls as if a future WPF release would support XAML base-classes, and wait for this next release with a temporary solution ?<br><br>What is your opinion about this ?<br></span></font>Mon, 12 May 2008 08:56:28 Z2008-05-12T08:56:28Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#aa738aa4-1f51-4f7c-8a79-250b55499dd1http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#aa738aa4-1f51-4f7c-8a79-250b55499dd1bootishttp://social.msdn.microsoft.com/Profile/en-US/?user=bootisUserControl Inheritance<font size=2><span style="font-family:Arial">No answer... Is my question stupid? (don't hesitate...), and if yes: why?<br></span></font>Tue, 13 May 2008 07:18:09 Z2008-05-13T07:18:09Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#367f63e1-2fbd-425b-a573-21db56dafda4http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#367f63e1-2fbd-425b-a573-21db56dafda4Rob Relyeahttp://social.msdn.microsoft.com/Profile/en-US/?user=Rob%20RelyeaUserControl Inheritance<p align=left><font face=Arial size=2>3.5sp1 is the next release (just went to Beta).  It hasn't yet fixed this problem.</font></p> <p align=left>I'm unsure if the release after that will support it.</p> <p align=left> </p> <p align=left>I recommend you plan to proceed without it for anywhere from 1 - 3 years...I can't promise when we will address...</p> <p align=left> </p> <p>Thanks, Rob</p> <p><span style="color:#1f497d"><font face=Verdana color="#000000"><font size=2>Rob Relyea | Program Manager, WPF &amp; Xaml Language Team<br></font><a title="http://robrelyea.com/" href="http://robrelyea.com/"><font size=2>robrelyea.com</font></a><font size=2> | </font><a title="http://robrelyea.com/blog" href="http://robrelyea.com/blog"><font size=2>/blog</font></a><font size=2> | </font><a title="http://robrelyea.com/wpf" href="http://robrelyea.com/wpf"><font size=2>/wpf</font></a><font size=2> | </font><a title="http://robrelyea.com/xaml" href="http://robrelyea.com/xaml"><font size=2>/xaml</font></a></font></span></p>Tue, 13 May 2008 11:38:03 Z2008-05-13T11:38:03Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#0d8544db-fdac-40b4-a369-3fcb891a329chttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#0d8544db-fdac-40b4-a369-3fcb891a329cbootishttp://social.msdn.microsoft.com/Profile/en-US/?user=bootisUserControl Inheritance<font size=2><span style="font-family:Arial">Thanks much for your answer.<br>The most important is that you planned to fix the problem someday...<br></span></font>Tue, 13 May 2008 11:54:26 Z2008-05-13T11:54:26Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#00c2e17e-7ea6-45b8-aab8-af8d75497b6fhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#00c2e17e-7ea6-45b8-aab8-af8d75497b6fBrownie Pointshttp://social.msdn.microsoft.com/Profile/en-US/?user=Brownie%20PointsUserControl Inheritance<p>Just curious what are you trying to do in this case? Do you want the child control to have the exact same look as its parent but have different functionality? Or do you want to add additional controls to the child that weren't on the parent?</p>Tue, 17 Jun 2008 15:03:47 Z2008-06-17T15:03:47Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#829eac77-623a-4744-9398-54e6000c3356http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#829eac77-623a-4744-9398-54e6000c3356dayanandavthttp://social.msdn.microsoft.com/Profile/en-US/?user=dayanandavtUserControl InheritanceGo to ____.Thu, 02 Jul 2009 14:13:41 Z2009-07-02T14:13:41Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#6acf58d8-f0a3-4df8-9b9a-0897998b28b5http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#6acf58d8-f0a3-4df8-9b9a-0897998b28b5rgregoryTSChttp://social.msdn.microsoft.com/Profile/en-US/?user=rgregoryTSCUserControl Inheritance<p>I have done what you did in UserControl2.Xaml with some success.   You need to add a namespace where your UserControl1 is defined.  See below<br/><br/>&lt;src:UserControl1 x:Class=&quot;MDIWindows.Child&quot;<br/>    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br/>    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; xmlns<img src="http://forums.microsoft.com/MSDN/emoticons/emotion-7.gif" alt="Tongue Tied">rc=&quot;clr-namespace:MDIWindows&quot;<br/>    xmlns:srs=&quot;myNamespace&quot;<br/>    Height=&quot;300&quot; Width=&quot;300&quot;&gt;<br/>  <br/>&lt;/src:UserControl1&gt;<br/><br/>This approach will compile and execute, but will not display correctly in the Visual Studio Designer.  I believe this is a bug.<br/>Your Solution Build will succeed, even though you will get an error when you try to update the Designer window.</p>Tue, 07 Jul 2009 13:47:16 Z2009-07-07T13:47:16Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#054be7d4-fa34-4d39-bfed-a71868c5a408http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/80eb3f57-9907-4bf7-9f48-b75043b8c97b#054be7d4-fa34-4d39-bfed-a71868c5a408Svetoslav Savovhttp://social.msdn.microsoft.com/Profile/en-US/?user=Svetoslav%20SavovUserControl InheritanceCheck this out: <br/> <a title="User control inheritance in WPF with XAML" href="http://svetoslavsavov.blogspot.com/2009/09/user-control-inheritance-in-wpf.html" title="User control inheritance in WPF with XAML">http://svetoslavsavov.blogspot.com/2009/09/user-control-inheritance-in-wpf.html</a>Sat, 12 Sep 2009 10:28:59 Z2009-09-12T10:28:59Z