Make a Custom Window (inherit from <Window>)<p>How can I make a custom Window?</p> <p>I want build a custom Windows to give him custom Properties.</p> <p>And make based on myCustomWindow other CustomWindows.</p> <p>And this Windows shold be visible in the FormsDesigner.</p> <p> </p>© 2009 Microsoft Corporation. All rights reserved.Thu, 25 Sep 2008 20:30:00 Z4f0cd7e3-65fa-4d2a-b29f-492e4209641chttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#4f0cd7e3-65fa-4d2a-b29f-492e4209641chttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#4f0cd7e3-65fa-4d2a-b29f-492e4209641cHorst Kleinhttp://social.msdn.microsoft.com/Profile/en-US/?user=Horst%20KleinMake a Custom Window (inherit from <Window>)<p>How can I make a custom Window?</p> <p>I want build a custom Windows to give him custom Properties.</p> <p>And make based on myCustomWindow other CustomWindows.</p> <p>And this Windows shold be visible in the FormsDesigner.</p> <p> </p>Fri, 17 Nov 2006 16:29:41 Z2006-12-07T09:13:50Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#05c0b378-6608-46bf-bf9c-6bcb0440e4c9http://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#05c0b378-6608-46bf-bf9c-6bcb0440e4c9Horst Kleinhttp://social.msdn.microsoft.com/Profile/en-US/?user=Horst%20KleinMake a Custom Window (inherit from <Window>)<P class=MsoNormal><FONT face="Times New Roman, Times, Serif" color=#000000 size=3><SPAN lang=EN-US style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri"><STRONG>The answer&nbsp;to my&nbsp;support request&nbsp;to Microsoft:</STRONG></SPAN></FONT></P> <P class=MsoNormal><FONT face=Calibri color=#1f497d size=2><SPAN lang=EN-US style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri">Xaml does not support visual inheritance.&nbsp; Xaml provides the complete element tree for a class, and there is no defined way to merge two trees together.&nbsp; I also don’t think I’d use templating for this.&nbsp; I think instead I would use user controls and create a control that defined the common parts of the Window and use that control on every subsequent window.&nbsp; I managed to make this work.&nbsp; I created a “WindowSurface” control that derived from UserControl.&nbsp; It has the following XAML and code:</SPAN></FONT></P> <P class=MsoNormal><FONT face=Calibri color=#1f497d size=2><SPAN lang=EN-US style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri">&nbsp;</SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">UserControl</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">xmlns</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">http://schemas.microsoft.com/winfx/2006/xaml/presentation</SPAN></FONT>"<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">xmlns:x</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">http://schemas.microsoft.com/winfx/2006/xaml</SPAN></FONT>"<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">x:Class</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">CiderWindowsApplication31.WindowSurface</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue"> </SPAN></FONT><FONT color=red><SPAN style="COLOR: red">FlowDirection</SPAN></FONT><FONT color=blue><SPAN style="COLOR: blue">=</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">RightToLeft</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue"> &gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">DockPanel</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"> </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">LastChildFill</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">True</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">StackPanel</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">DockPanel.Dock</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">Bottom</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue"> </SPAN></FONT><FONT color=red><SPAN style="COLOR: red">Orientation</SPAN></FONT><FONT color=blue><SPAN style="COLOR: blue">=</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">Horizontal</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Button</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Cancel<FONT color=blue><SPAN style="COLOR: blue">&lt;/</SPAN></FONT><FONT color=#a31515><SPAN style="COLOR: #a31515">Button</SPAN></FONT><FONT color=blue><SPAN style="COLOR: blue">&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Button</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">OK<FONT color=blue><SPAN style="COLOR: blue">&lt;/</SPAN></FONT><FONT color=#a31515><SPAN style="COLOR: #a31515">Button</SPAN></FONT><FONT color=blue><SPAN style="COLOR: blue">&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; &lt;/</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">StackPanel</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">ContentControl</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"> </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">Name</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">surfaceContent</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">&gt;&lt;/</SPAN></FONT><FONT color=#a31515><SPAN style="COLOR: #a31515">ContentControl</SPAN></FONT><FONT color=blue><SPAN style="COLOR: blue">&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; &lt;/</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">DockPanel</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&lt;/</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">UserControl</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;</SPAN></FONT></P> <P class=MsoNormal><FONT face=Calibri color=#1f497d size=2><SPAN lang=EN-US style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri"></SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.ComponentModel;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows.Controls;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows.Data;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows.Input;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows.Documents;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows.Media;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows.Shapes;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">using</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Windows.Markup;</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;</SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">namespace</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> CiderWindowsApplication31 {<BR></SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <FONT color=gray><SPAN style="COLOR: gray">///</SPAN></FONT><FONT color=green><SPAN style="COLOR: green"> </SPAN></FONT><FONT color=gray><SPAN style="COLOR: gray">&lt;summary&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <FONT color=gray><SPAN style="COLOR: gray">///</SPAN></FONT><FONT color=green><SPAN style="COLOR: green"> Interaction logic for Window1.xaml<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <FONT color=gray><SPAN style="COLOR: gray">///</SPAN></FONT><FONT color=green><SPAN style="COLOR: green"> </SPAN></FONT><FONT color=gray><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN></FONT></SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; [<FONT color=#2b91af><SPAN style="COLOR: #2b91af">ContentProperty</SPAN></FONT>(<FONT color=#a31515><SPAN style="COLOR: #a31515">"SurfaceContent"</SPAN></FONT>)]<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <FONT color=blue><SPAN style="COLOR: blue">public</SPAN></FONT> <FONT color=blue><SPAN style="COLOR: blue">partial</SPAN></FONT> <FONT color=blue><SPAN style="COLOR: blue">class</SPAN></FONT> <FONT color=#2b91af><SPAN style="COLOR: #2b91af">WindowSurface</SPAN></FONT> : <FONT color=#2b91af><SPAN style="COLOR: #2b91af">UserControl</SPAN></FONT> {</SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=blue><SPAN style="COLOR: blue">public</SPAN></FONT> WindowSurface()<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <FONT color=blue><SPAN style="COLOR: blue">base</SPAN></FONT>() {<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponent();<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=blue><SPAN style="COLOR: blue">public</SPAN></FONT> <FONT color=blue><SPAN style="COLOR: blue">object</SPAN></FONT> SurfaceContent {<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=blue><SPAN style="COLOR: blue">get</SPAN></FONT> { <FONT color=blue><SPAN style="COLOR: blue">return</SPAN></FONT> surfaceContent.Content; }<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=blue><SPAN style="COLOR: blue">set</SPAN></FONT> { surfaceContent.Content = <FONT color=blue><SPAN style="COLOR: blue">value</SPAN></FONT> ; }<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; }<BR></SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">}</SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT></P> <P class=MsoNormal><FONT face=Calibri color=#1f497d size=2><SPAN lang=EN-US style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri">Next, I placed this control on a Window like this:<BR></SPAN></FONT></P> <P class=MsoNormal><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Window</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">xmlns</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">http://schemas.microsoft.com/winfx/2006/xaml/presentation</SPAN></FONT>"<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">xmlns:x</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">http://schemas.microsoft.com/winfx/2006/xaml</SPAN></FONT>"<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">xmlns:l</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">clr-namespace:CiderWindowsApplication31</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">&nbsp;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">x:Class</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">CiderWindowsApplication31.Window1</SPAN></FONT>"<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">Title</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">Main Window</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">l:WindowSurface</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Grid</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Button</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"> </SPAN></FONT><FONT face="Courier New" color=red size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">Margin</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</SPAN></FONT><FONT face="Courier New" size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<FONT color=blue><SPAN style="COLOR: blue">143,102,55,111</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue"> </SPAN></FONT><FONT color=red><SPAN style="COLOR: red">Name</SPAN></FONT><FONT color=blue><SPAN style="COLOR: blue">=</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">button1</SPAN></FONT>"<FONT color=blue><SPAN style="COLOR: blue">&nbsp; &gt;</SPAN></FONT>Button<FONT color=blue><SPAN style="COLOR: blue">&lt;/</SPAN></FONT><FONT color=#a31515><SPAN style="COLOR: #a31515">Button</SPAN></FONT><FONT color=blue><SPAN style="COLOR: blue">&gt;<BR></SPAN></FONT></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; &lt;/</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Grid</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&nbsp; &lt;/</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">l:WindowSurface</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;<BR></SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&lt;/</SPAN></FONT><FONT face="Courier New" color=#a31515 size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Window</SPAN></FONT><FONT face="Courier New" color=blue size=2><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;</SPAN></FONT></P> <P class=MsoNormal><FONT face=Calibri color=#1f497d size=2><SPAN lang=EN-US style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri"><SPAN lang=EN-US style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri">Once I did this, I can add controls to the “surface” area of the user control</SPAN>&nbsp;</SPAN></FONT></P>Thu, 07 Dec 2006 09:12:44 Z2006-12-07T09:13:50Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#d9f34491-27a2-4840-8388-403cb689d73ahttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#d9f34491-27a2-4840-8388-403cb689d73aZhou Yonghttp://social.msdn.microsoft.com/Profile/en-US/?user=Zhou%20YongMake a Custom Window (inherit from <Window>)I think you just introduce an extra complexity to the UserControl by adding the &quot;SurfaceContent&quot; property, why not directly use Content property instead.<br>And what do you mean by &quot;<span><span id="_ctl0_MainContent__ctl0_PostForm_ReplyBody" class=txt4><font color="#1f497d" face=Calibri size=2><span style="font-size:11pt;color:rgb(31, 73, 125);font-family:Calibri" lang=EN-US>Xaml does not support visual inheritance&quot;?<br><br></span></font></span></span>ShevaThu, 07 Dec 2006 12:03:00 Z2006-12-07T12:03:00Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#02cdcf55-8745-4fac-9a98-01cc56a7c8f7http://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#02cdcf55-8745-4fac-9a98-01cc56a7c8f7Horst Kleinhttp://social.msdn.microsoft.com/Profile/en-US/?user=Horst%20KleinMake a Custom Window (inherit from <Window>)<p class=MsoNormal><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">I use VS2005 SP1 + WPF-Extensions and have developed following Window...</span></font></p> <p class=MsoNormal><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&lt;</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">Window</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">x:Class</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">VitoWindow</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">    </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">xmlns</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">    </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">xmlns:x</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">    </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">Title</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">Custom Window</span></font>&quot;<font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red">Height</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">327</span></font>&quot;<font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red">Width</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">546</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">    &gt;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">    &lt;</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">Grid</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;        <br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">    &lt;/</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">Grid</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&lt;/</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">Window</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;</span></font></p> <p class=MsoNormal><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"></span></font></p> <p class=MsoNormal><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">In another Window I wants to “inherit” this Window (and some other XAML-Controls like a button)...</span></font></p> <p class=MsoNormal><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"></span></font></p> <p class=MsoNormal><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&lt;</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">v:VitoWindow<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">      </span></font><font face="Courier New" color=red size=2><span style="font-size:10pt;color:red;font-family:'Courier New'">xmlns</span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">      </span></font><font face="Courier New" color=red size=2><span style="font-size:10pt;color:red;font-family:'Courier New'">xmlns:x</span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">      </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">xmlns:v</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">clr-namespace:CustomControlLibrary;assembly=CustomControlLibrary</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">      </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">xml:lang</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">de-DE</span></font>&quot;</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">x:Class</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">Window1</span></font>&quot;</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">x:Name</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">Window</span></font>&quot;</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">Title</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">VitoWindow</span></font>&quot;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">      </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">Width</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">640</span></font>&quot;<font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red">Height</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">480</span></font>&quot;<font color=blue><span style="color:blue"> <br>      </span></font><font color=red><span style="color:red">xmlns:d</span></font><font color=blue><span style="color:blue">=</span></font><font color=blue><span style="color:blue"><a title="http://schemas.microsoft.com/expression/blend/2006" href="http://schemas.microsoft.com/expression/blend/2006">http://schemas.microsoft.com/expression/blend/2006</a></span></font><font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red"><br>      mlns:mc</span></font><font color=blue><span style="color:blue">=</span></font><font color=blue><span style="color:blue"><a title="http://schemas.openxmlformats.org/markup-compatibility/2006" href="http://schemas.openxmlformats.org/markup-compatibility/2006">http://schemas.openxmlformats.org/markup-compatibility/2006</a></span></font><font color=blue><span style="color:blue"> <br>      </span></font><font color=red><span style="color:red">mc:Ignorable</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">d</span></font>&quot;<font color=blue><span style="color:blue">&gt;<br></span></font></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">     &lt;</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">Grid</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">x:Name</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">LayoutRoot</span></font>&quot;<font color=blue><span style="color:blue">&gt;<br></span></font></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">            &lt;</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">Grid.ColumnDefinitions</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">                 &lt;</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">ColumnDefinition</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">Width</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">*</span></font>&quot;<font color=blue><span style="color:blue">/&gt;<br></span></font></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">            &lt;/</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">Grid.ColumnDefinitions</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;<br></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">            &lt;</span></font><font face="Courier New" color="#a31515" size=2><span lang=EN-GB style="font-size:10pt;color:#a31515;font-family:'Courier New'">v:VitoButton</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font><font face="Courier New" color=red size=2><span lang=EN-GB style="font-size:10pt;color:red;font-family:'Courier New'">Margin</span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">=</span></font><font face="Courier New" size=2><span lang=EN-GB style="font-size:10pt;font-family:'Courier New'">&quot;<font color=blue><span style="color:blue">138.288,62,315.712,0</span></font>&quot;<font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red">VerticalAlignment</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">Top</span></font>&quot;<font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red">Height</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">54</span></font>&quot;<font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red">Content</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">VitoButton</span></font>&quot;<font color=blue><span style="color:blue"> </span></font><font color=red><span style="color:red">d:LayoutOverrides</span></font><font color=blue><span style="color:blue">=</span></font>&quot;<font color=blue><span style="color:blue">HorizontalAlignment</span></font>&quot;<font color=blue><span style="color:blue">/&gt;<br></span></font></span></font><font face="Courier New" color=blue size=2><span lang=EN-GB style="font-size:10pt;color:blue;font-family:'Courier New'">      </span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">&lt;/</span></font><font face="Courier New" color="#a31515" size=2><span style="font-size:10pt;color:#a31515;font-family:'Courier New'">Grid</span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;<br></span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">&lt;/</span></font><font face="Courier New" color="#a31515" size=2><span style="font-size:10pt;color:#a31515;font-family:'Courier New'">v:VitoWindow</span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;<br></span></font></p> <p class=MsoNormal><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'">...but he gets...</span></font><font face="Courier New" color=blue size=2><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></font></p> <p class=MsoNormal><font face=Arial size=2><span lang=EN-GB style="font-size:10pt;font-family:Arial">Warning           1          'CustomControlLibrary.VitoWindow' cannot be the root of a XAML file because it was defined using XAML. </span></font><font face=Arial size=2><span style="font-size:10pt;font-family:Arial">Line 2 Position 2. Window1.xaml  2          2            CustomWindow</span></font></p> <p class=MsoNormal><font face="Arial Black, Geneva, Arial, Sans-serif" color="#ff0000" size=5><span style="font-size:10pt;font-family:Arial"><strong>And THIS is not supported in XAML! </strong></span></font></p> <p class=MsoNormal><font face="Arial Black, Geneva, Arial, Sans-serif" size=4><span style="font-size:10pt;font-family:Arial">I tried on this way to give the Original Window some Custom Properties and Methods</span></font></p> <p class=MsoNormal><font face="Arial Black, Geneva, Arial, Sans-serif" size=4><span style="font-size:10pt;font-family:Arial">Horst</span></font></p>Thu, 07 Dec 2006 13:06:06 Z2006-12-07T13:06:06Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#cab1e304-c706-4b13-9e4c-225817471313http://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#cab1e304-c706-4b13-9e4c-225817471313Zhou Yonghttp://social.msdn.microsoft.com/Profile/en-US/?user=Zhou%20YongMake a Custom Window (inherit from <Window>)For current bit of WPF, you cannot subclass from xaml generated class, but you can work around this by doing something like the following:<br>First off, create an custom WPF control library project, and then declare your custom window this way:<br> <div style="background:white none repeat scroll 0%;font-family:Verdana;font-size:9pt;color:black"><pre style="margin:0px"><span style="color:blue;font-family:Verdana">namespace</span><span style="font-family:Verdana"> CustomControlLib</span></pre><pre style="margin:0px"><span style="font-family:Verdana">{</span></pre><pre style="margin:0px"><span style="font-family:Verdana">    </span><span style="color:blue;font-family:Verdana">public</span><span style="font-family:Verdana"> </span><span style="color:blue;font-family:Verdana">class</span><span style="font-family:Verdana"> </span><span style="color:teal;font-family:Verdana">CustomWindow</span><span style="font-family:Verdana"> : </span><span style="color:teal;font-family:Verdana">Window</span></pre><pre style="margin:0px"><span style="font-family:Verdana">    {</span></pre><pre style="margin:0px"><span style="font-family:Verdana">        </span><span style="color:blue;font-family:Verdana">static</span><span style="font-family:Verdana"> CustomWindow()</span></pre><pre style="margin:0px"><span style="font-family:Verdana">        {</span></pre><pre style="margin:0px"><span style="font-family:Verdana">            DefaultStyleKeyProperty.OverrideMetadata(</span><span style="color:blue;font-family:Verdana">typeof</span><span style="font-family:Verdana">(</span><span style="color:teal;font-family:Verdana">CustomWindow</span><span style="font-family:Verdana">), </span><span style="color:blue;font-family:Verdana">new</span><span style="font-family:Verdana"> </span><span style="color:teal;font-family:Verdana">FrameworkPropertyMetadata</span><span style="font-family:Verdana">(</span><span style="color:blue;font-family:Verdana">typeof</span><span style="font-family:Verdana">(</span><span style="color:teal;font-family:Verdana">CustomWindow</span><span style="font-family:Verdana">)));</span></pre><pre style="margin:0px"><span style="font-family:Verdana">        }</span></pre><pre style="margin:0px"> </pre><pre style="margin:0px"><span style="font-family:Verdana">    }</span></pre><pre style="margin:0px"><span style="font-family:Verdana">}</span></pre></div> <br>In the Themes\generic.xaml file:<br> <div style="background:white none repeat scroll 0%;font-family:Verdana;font-size:9pt;color:black"><pre style="margin:0px"><span style="color:blue;font-family:Verdana">&lt;</span><span style="color:maroon;font-family:Verdana">ResourceDictionary</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">xmlns</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    </span><span style="color:red;font-family:Verdana">xmlns:x</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">http://schemas.microsoft.com/winfx/2006/xaml</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    </span><span style="color:red;font-family:Verdana">xmlns:cc</span><span style="color:blue;font-family:Verdana"> =</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">clr-namespace:CustomControlLib</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    &gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">  &lt;</span><span style="color:maroon;font-family:Verdana">Style</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">TargetType</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">{x:Type cc:CustomWindow}</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    &lt;</span><span style="color:maroon;font-family:Verdana">Setter</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Property</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">AllowsTransparency</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Value</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">True</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">/&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    &lt;</span><span style="color:maroon;font-family:Verdana">Setter</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Property</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">WindowStyle</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Value</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">None</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">/&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    &lt;</span><span style="color:maroon;font-family:Verdana">Setter</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Property</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">Template</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">      &lt;</span><span style="color:maroon;font-family:Verdana">Setter.Value</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">        &lt;</span><span style="color:maroon;font-family:Verdana">ControlTemplate</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">TargetType</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">{x:Type cc:CustomWindow}</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">          &lt;</span><span style="color:maroon;font-family:Verdana">Border</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">BorderBrush</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">Green</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">BorderThickness</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">1</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">CornerRadius</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">10</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">            &lt;</span><span style="color:maroon;font-family:Verdana">AdornerDecorator</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">              &lt;</span><span style="color:maroon;font-family:Verdana">ContentPresenter</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">                </span><span style="color:red;font-family:Verdana">ContentTemplate</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">{TemplateBinding ContentControl.ContentTemplate}</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">                </span><span style="color:red;font-family:Verdana">Content</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">{TemplateBinding ContentControl.Content}</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> /&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">            &lt;/</span><span style="color:maroon;font-family:Verdana">AdornerDecorator</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">          &lt;/</span><span style="color:maroon;font-family:Verdana">Border</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">        &lt;/</span><span style="color:maroon;font-family:Verdana">ControlTemplate</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">      &lt;/</span><span style="color:maroon;font-family:Verdana">Setter.Value</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    &lt;/</span><span style="color:maroon;font-family:Verdana">Setter</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">  &lt;/</span><span style="color:maroon;font-family:Verdana">Style</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">&lt;/</span><span style="color:maroon;font-family:Verdana">ResourceDictionary</span><span style="color:blue;font-family:Verdana">&gt;</span></pre></div> <br>Then you can optionally do something like this in the AssemblyInfo.cs:<br> <div style="background:white none repeat scroll 0%;font-family:Verdana;font-size:9pt;color:black"><pre style="margin:0px"><span style="font-family:Verdana">[assembly: </span><span style="color:teal;font-family:Verdana">XmlnsDefinition</span><span style="font-family:Verdana">(</span><span style="color:maroon;font-family:Verdana">&quot;http://schemas.sheva.com/winfx/2006/xaml/presentation&quot;</span><span style="font-family:Verdana">, </span><span style="color:maroon;font-family:Verdana">&quot;CustomControlLib&quot;</span><span style="font-family:Verdana">)]</span></pre></div> <br>Lastly, create a WPF application project, and declare the window this way:<br><br> <div style="background:white none repeat scroll 0%;font-family:Verdana;font-size:9pt;color:black"><pre style="margin:0px"><span style="color:blue;font-family:Verdana">&lt;</span><span style="color:maroon;font-family:Verdana">cc:CustomWindow</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">x:Class</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">CustomWindowDemo.Window1</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    </span><span style="color:red;font-family:Verdana">xmlns</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    </span><span style="color:red;font-family:Verdana">xmlns:cc</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">http://schemas.sheva.com/winfx/2006/xaml/presentation</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    </span><span style="color:red;font-family:Verdana">xmlns:x</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">http://schemas.microsoft.com/winfx/2006/xaml</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    </span><span style="color:red;font-family:Verdana">Title</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">CustomWindowDemo</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Height</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">300</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Width</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">300</span><span style="font-family:Verdana">&quot;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    &gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">  &lt;</span><span style="color:maroon;font-family:Verdana">Grid</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">    &lt;</span><span style="color:maroon;font-family:Verdana">Button</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Content</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">This is a custom window</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana"> </span><span style="color:red;font-family:Verdana">Margin</span><span style="color:blue;font-family:Verdana">=</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">5</span><span style="font-family:Verdana">&quot;</span><span style="color:blue;font-family:Verdana">/&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">  &lt;/</span><span style="color:maroon;font-family:Verdana">Grid</span><span style="color:blue;font-family:Verdana">&gt;</span></pre><pre style="margin:0px"><span style="color:blue;font-family:Verdana">&lt;/</span><span style="color:maroon;font-family:Verdana">cc:CustomWindow</span><span style="color:blue;font-family:Verdana">&gt;</span></pre></div> <br>Just compile and run this, it works perfectly. and you can actually specify additional DPs to your CustomWindow class.<br><br>Sheva<br><br><br>Thu, 07 Dec 2006 14:42:49 Z2006-12-07T14:42:49Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#169b0bc2-d3b2-4a2c-8d62-92e405d03d37http://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#169b0bc2-d3b2-4a2c-8d62-92e405d03d37Umit Gunduzhttp://social.msdn.microsoft.com/Profile/en-US/?user=Umit%20GunduzMake a Custom Window (inherit from <Window>)<p>  <b><a id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedBy" href="http://forums.microsoft.com/MSDN/User/Profile.aspx?UserID=718&amp;SiteID=1">Zhou Yong</a> this inheritance method is ok. Already i use to this method but my problem that,</b></p> <p><strong></strong> </p> <p><strong>I have an example BasePage, BrowseBasePage, and SearcherBrowseBasePage. These is my framework pages</strong></p> <p><strong></strong> </p> <p><strong>BrowseBasePage inherit BasePage and SearcherBrowseBasePage inherit BrowseBasePage </strong></p> <p><strong></strong> </p> <p><strong>after than i create a new page is MyBrowsePage and this page inherit SearcherBrowseBasePage </strong></p> <p><strong></strong> </p> <p><strong>i can code behind inheritance. But i can't visual inheritance although use <a id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedBy" href="http://forums.microsoft.com/MSDN/User/Profile.aspx?UserID=718&amp;SiteID=1">Zhou Yong</a>'s visual inheritance method</strong></p> <p><strong></strong> </p> <p><strong>Can i do this inheritance.</strong></p> <p><strong></strong> </p> <p><strong>can you help me? </strong></p> <p><strong></strong> </p> <p><strong>Thanks</strong></p>Sat, 23 Jun 2007 16:22:37 Z2007-06-23T16:22:37Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#58811e1e-ad52-4b19-b3e5-a30df1c19750http://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#58811e1e-ad52-4b19-b3e5-a30df1c19750Grzegorz Wiśniewskihttp://social.msdn.microsoft.com/Profile/en-US/?user=Grzegorz%20Wi%u015bniewskiMake a Custom Window (inherit from <Window>)Zhou Yong I have a question. In Class library Dolphin.Windows.dll I have declare class:<br><br>namespace Dolphin.Windows<br>{<br>    public class Window : System.Windows.Window<br>    {<br>        public Window():base()<br>        {<br>        }<br>    }<br>}<br><br>In this project in AssemblyInfo.cs I have:<br><br>[assembly: System.Windows.Markup.XmlnsDefinition(&quot;http://schemas.mk-system.pl/winfx/2006/xaml/presentation&quot;, &quot;Dolphin.Windows&quot;)]<br><br>I want using Dolphin.Windows.Window in project Mirage. In Main.xaml.cs I set:<br><br>namespace Mirage.Main<br>{<br>    public partial class WinMain : Dolphin.Windows.Window<br>    {<br>        public WinMain()<br>        {<br>            InitializeComponent();<br>        }<br>    }<br>}<br><br>And in Main.xaml&quot;<br><br>&lt;dolphin:Window<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>    x:Class=&quot;Mirage.Main.WinMain&quot;<br>    xmlns:dolphin=&quot;http://schemas.mk-system.pl/winfx/2006/xaml/presentation&quot;<br>    Title=&quot;Mirage&quot;<br>    Width=&quot;800&quot;<br>    Height=&quot;600&quot;<br>    MinWidth=&quot;800&quot;<br>    MinHeight=&quot;600&quot;<br>    &gt;<br>&lt;/dolphin:Window&gt;<br><br>When I compile project I have error:<br><br>Error    1    Invalid XmlnsDeclaration occurs in assembly 'Mirage, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. XmlnsDeclaration references a namespace 'Dolphin.Windows' that is not in the assembly.    D:\Application C#\Mirage\Mirage\Main\WinMain.xaml    1    1    Mirage<br><br>And:<br><br>Error    2    The type 'dolphin:Window' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.    D:\Application C#\Mirage\Mirage\Main\WinMain.xaml    1    2    Mirage<br><br>What is wrong?<br> Thu, 25 Sep 2008 17:07:55 Z2008-09-25T17:07:55Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#362712fa-b085-4e21-97a4-b7afc12c0ba4http://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#362712fa-b085-4e21-97a4-b7afc12c0ba4leblancmeneseshttp://social.msdn.microsoft.com/Profile/en-US/?user=leblancmenesesMake a Custom Window (inherit from <Window>)'Dolphin.Windows' that is not in the assembly.<br><br>i think its looking in the wrong location.<br><br>xmlns:dolphin=&quot;http://schemas.mk-system.pl/winfx/2006/xaml/presentation&quot;<br>should be:<br>xmlns:dolphin=&quot;clr-namespace:Dolphin.Windows;assembly=Dolphin.Windows&quot;<br><br>&lt;dolphin:Window  will now work.<br>x:Class=&quot;Mirage.Main.WinMain&quot;  should reference your partial class the xaml will inherit from.<br><br><br><br> <hr size="1" align="left" width="25%">leblancThu, 25 Sep 2008 19:07:06 Z2008-09-25T19:07:06Zhttp://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#fb834d59-fa70-49c4-9dab-ac8d79533163http://social.msdn.microsoft.com/Forums/en/wpf/thread/4f0cd7e3-65fa-4d2a-b29f-492e4209641c#fb834d59-fa70-49c4-9dab-ac8d79533163Grzegorz Wiśniewskihttp://social.msdn.microsoft.com/Profile/en-US/?user=Grzegorz%20Wi%u015bniewskiMake a Custom Window (inherit from <Window>)When I instal VS C# 2008 SP 1 I have error in xaml file, when I use:<br>xmlns:dolphin=&quot;clr-namespace:Dolphin.Windows;assembly=Dolphin.Windows&quot;<br><br>Project compile OK, but in designer i have error. When I project run in computer where is not SP 1 project compile OK and designer work OK. I think this error is in computer where is SP 1.<br><br>This is a bug in SP 1?<br> Thu, 25 Sep 2008 20:30:00 Z2008-09-25T20:30:00Z