tags:

views:

51

answers:

5

Instead of using all the base wpf controls such as Label, TextBox, Grid, ect. I want to create a sub class of all these base controls and use the sub class.

e.g. public class MyTextBox : TextBox {}

They would be dummy classes for now, but it leaves room to be expandable in-case I need to in the future. Is this recommended or is it unnecessary?

+1  A: 

It sounds unnecessary, unproductive, and definitely not recommended!

Cheers,
Berryl

Berryl
Why stop there? Go all the way back to System.Object and derive your own. Why on Earth would you do such a thing?!?!?
Wonko the Sane
A: 

This sort of approach tends to be overkill. Where it does have its uses is when you know you will need to change the base UI controls at some point in the future. So if you were using a third party control suite then you might look at this approach, but you wouldn't want to do it with the MS controls as they are baked into the framework - you aren't going to change those!

Another approach is to ensure you follow a pattern like MVVM - this ensures that you have a UI that is nicely separated from your working code, and you can change controls with the minimum impact.

slugster
+4  A: 

This is a text-book definition of yagni

Steve Ellinger
A: 

If for some reason you need a subclass in the future it will be much easier to simply create it then than it to do lots of unnecessary work now.

Brian Ensink
A: 

I think this is unnecessary. We can easily override the look and feel of a control using styles. In case you want to add properties, you can use attached properties.

Michael Detras