When to add a Component Class vs User Control?

alexD picture alexD · Sep 21, 2009 · Viewed 20.5k times · Source

I have a general idea, and there are some obvious cases, but there are also some gray areas for me - when is it best to use to extend from a component and when is it best to create a user control? This pertains to a specific work problem I am trying to solve, but the specifics of that are not important - a general answer to this question is enough for me.

Answer

Reed Copsey picture Reed Copsey · Sep 21, 2009

In WPF and Windows Forms, both, the main difference is that a UserControl is meant to be a collection of controls - a reusable, single object "composed" from multiple controls themselves.

You'd impelemnt a Component/CustomControl/Control instead of a UserControl if you are making a single, primitive control with new behavior, instead of making a "control" that's composed of smaller controls. Component usually is a non-visual behavior, where a CustomControl/Control is usually for a visual control.