Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't there visual inheritance in WPF?

In Windows Forms, it was useful at times to have one window that inherited from another window. But in WPF, this is not allowed. Why is there no visual inheritance for WPF windows?

like image 823
epotter Avatar asked Apr 03 '09 14:04

epotter


People also ask

What is Visual inheritance in C#?

Visual inheritance enables you to see the controls on the base form and to add new controls. In this walkthrough you will create a base form and compile it into a class library. You will import this class library into another project and create a new form that inherits from the base form.

How to inherit form in vb net?

To inherit a form, you first must add the form you want to use to the project. Then, by changing a single line of code, you can inherit the objects from the existing form. To see how this works, start a new project and create a form that resembles the one in Figure 3.19.

What is Visual inheritance in VB net?

- VB. NET's visual inheritance creates forms for reuse. - Form components which are controlled is allowed to change in the inherited form. When you inherit a form, you also can extend its functionality with new features in its visual layout, as well as its properties and methods.


3 Answers

The reason WPF does not support visual inheritance is due to the fact that the form design is achieved via markup (.xaml) as opposed to winforms which use code-behind to produce the layout. Code-behind is extensible and markup is not. The same goes for web forms. Master pages in asp.net offer a quasi visual inheritance. So it is a trade off, markup offers the benefit of a clear separation of layout and data whereas code-behind offer visual extensibility. It is a bit of a shame since visual extensibility works so well in creating consistency in the GUI as well as very rapid development. Well, it seems flare is more in demand than functionality. WPF is just ok...

like image 104
Basil Wancer Avatar answered Oct 21 '22 17:10

Basil Wancer


WPF is deliberately very, very different from Windows Forms. The composability model is not based on Windows, but on classes like Dependency Object, Visual, UIElement. You can also dramatically modify the behavior of existing things using control templates, styles, data binding and other techniques.

I encourage you to experiment! WPF is very easy to prototype with

like image 32
Foredecker Avatar answered Oct 21 '22 16:10

Foredecker


In WPF, a large effort was made to separate visual from logical. Because of this, there is a LARGE amount of freedom to make the UI look however you want. All of the controls, including windows, are "lookless". You can provide your own look via templates and styles. A default visual style has been provided that makes everything look like you would expect, but you don't have to use it.

like image 36
Muad'Dib Avatar answered Oct 21 '22 16:10

Muad'Dib