Inherited Form in WPF
In Windows Forms, I usually create a parent Windows Form as a Master Form, then create Forms inherting from thast master form.
How to do the same in WPF?
Thanks a lot,
Regards
Answers
- Hi Bilal,
You could pick up the RibbonStyle sample I wrote a while ago to learn about how to create inherited window in WPF.
Hope this helps - As I've said that You cannot subclass from XAML generated class in current version of WPF, so basically the type of feature you are requesting is not supported and I think will not be supported in the future, since control templating is WPF's way of doing things in this regard
Hope this helps
All Replies
- You can use the same trick, but one thing you need to know is that in current version of WPF, you cannot subclass from XAML generated base class.
Hope this helps Thanks for the reply!
Can you show me the process of how to do the templating stuff with WPF? I mean, If I create a new WPF window there is no "Inherited Windows" in VS 2008. Can you guide please!
Thanks a lot,
RegardsJust a stab here, as I'm also a newbie at WPF (though not newbie in C#)...
I think what Marco means is that anything declared with xaml, (including the window) can be declared in c#, and would need to be that way for inheritance to work.
So instead of:
<CheckBox Height="16" Margin="72,0,86,88" Name="checkBox1" VerticalAlignment="Bottom">CheckBox</CheckBox>in Xaml,
You'd need:
CheckBox CheckBox1 = new CheckBox();etc, in the C# code file. Only things declared in the C# file would be inherited.
I'm sure someone will pop in with more, just trying to contribute a bit.
Bob
- Hi Bilal,
You could pick up the RibbonStyle sample I wrote a while ago to learn about how to create inherited window in WPF.
Hope this helps Thanks Marco,
As I saw from the example, it is not a UI inheritance, rather a class inheritance. I know that the UI inheritance was done through code, but I thought it was similar and simple like it was during the Windows Forms.
Thanks again.
- As I've said that You cannot subclass from XAML generated class in current version of WPF, so basically the type of feature you are requesting is not supported and I think will not be supported in the future, since control templating is WPF's way of doing things in this regard
Hope this helps Thanks Marco a lot for your help. Much appreciated. I will definitely look at the Control Templating!
I just need to ask one more question, I can see that, the actual size of a Form sometimes is not the same as the one at compile time. In WPF I see that the designer doesn't reflect what is really there in the application at runtime. I noticed that while reading in the book Professional WPF from Apress, there was an example about Photo Gallery, at design time it shows a shrinked Form and at runtime I see a full application.
Can you guide on this?
Thanks
- Well, you'd better ask this question at Cider designer forum instead, our product team members are actively monitoring that forum, so you would have better chance to get a good answer:
http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=169&SiteID=1
Hope this helps


