Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Custom Control Design Patterns. MVVM?

I am creating a custom control in WPF, it is the highly unoriginal example of a stock ticker that I am deriving from the Control type. My question is: Are there any recommnded design patterns for controls themselves (as opposed to the app)? I am using MVVM for the application as a whole but just wandered if it is good or bad practice to use such a design pattern with the control itself.

My reasons for thinking of using MVVM for the control is that:

  • It is a relatively complex control, in that it has a graphing ability and Dependency Properties of Midprice, Average etc etc
  • To have a ViewMOdel as part of it would make unit testing it easier (or even possible)
  • Makes the entire coding process easier, especially as I have a bespoke ObservableCollection of point types.

Any thought on the matter would be brilliant. I just don't know if this is good practice or not.

Many thanks

like image 384
jameschinnock Avatar asked Jul 11 '26 23:07

jameschinnock


1 Answers

1) Future Extensibility - Which I would say is the core when it comes to control development.
2) Good API Design - Create as much as Proof of Concepts.
3) Comes the pattern - If it is really big control. It is good to go with MVVM. But, learn to compromise it as well. Some times, we'll feel when it comes component development strict adherence to MVVM makes the control really complex.
4) Avoid over exposing of properties - Add properties as and when required. [Control feels it like an abuse, if properties are over exposed. ;)]
5) Make the control Lookless. Refer L for Lookless

General:
Try to make the control blendable from starting. It would help you to realize how good and usable from starting. Above all, it gives much satisfication and easy to track the completeness of the control.

When it comes to selecting a particular feature, think in two aspects:
1) Control's usability and
2) Control's Completeness.

like image 194
Prince Ashitaka Avatar answered Jul 13 '26 14:07

Prince Ashitaka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!