Control inheritance for consistent look and feel in a Windows Forms application
I am building a windows forms application where a very consistent look and feel across all modules is of very high priority. Apart from standard .NET controls it uses a lot of third party controls from different vendors. I would like to have the ability to change the entir开发者_运维技巧e look and feel of the application in one go, may be with upgraded versions of the software. Very much like skinning, but generally I have seen that skinning abilities by third party providers work well with their set of controls only while I have controls from multiple vendors.
I am planning to build a complete set of user controls inherited from either .NET controls or third party controls where relevant, and use our set of controls only. That way I might have to create a lot of controls (e.g. Text, DropDown, List, Grid, DTPicker, etc. etc.) but I guess I will have a reasonable command over the look and feel, i.e. I can propagate any changes in the base (e.g. use Tahoma font in all places instead of MS Sans Serif) by just rebuilding the complete app.
I was also thinking that the ability to change the font across the app alone, among others, is something that would cost almost all types of controls to be inherited.
Questions:
Do you feel that this is the right way (control inheritance) to proceed towards consistent look and feel across an app?
Do you support the ability to change the entire application font in one shot as a good requirement?
Suggestions, comments are greatly appreciated.
1). IMHO you will have bulky hierarchy. It's better, in my opinion, to have adapters for group of controls.
Infragistics, for instance, have complicates and, in many ways, illogical inheritance hierarchy. If I had to implement skinning quickly, I'd implemented skinning logic in a common form (or other container) class instead of creating large set of own controls.
Is there any chance to use WPF? I suspect the complexity of control development in Windows Forms goes up exponentially with every level of inheritance.
WPF provides built-in/designed-for skinning which is far easier to implement and maintain. I strongly recommend exploring that avenue and use WPF if you can.
as for Winforms, I know that a few Control Sets allow for suchlike things. Janus has a nice Set of Controls that can all register with a so-called VisualStyleManager. Changing the StyleManager's theme will automatically skin all Controls.
I don't implementing this yourself will make you happy...just go ahead and spend a few bucks on Janus or other components.
精彩评论