in

DĂ© specialist in .NET trainingen en consultancy

Jo-wen Mei

WPF & Inheritance

Probably one of the first things you've tried is to subclass Window (or Page/UserControl/etc) and expected to get the xaml for free in derived classes...

This is called "visual inheritance", and it doesn't work as expected (yet)....  This is a major issue for WPF.

 

Code inheritance is not a problem, and works as we're used to. As everything we do in Xaml, can be done in code there's no loss from a functional perspective...  it's just too much work

 

So you can create an (abstract) base class that derives from Window (code only!), and derive new windows (including xaml!) from your custom base class...

It's possible to make your base class abstract, unfortunately you loose CIDER (Visual Studio Designer) support. Blend can still create classes that are derived from an abstract class though.

Here's an example

 

Note: if you download the Blend SP1 you get another 60 days for your trial version :)

Comments

No Comments