WPF: CustomControl or UserControl?

March 23, 2010

one comment

While designing anew window, WPF architecture, I needed a NumericUpDown Control. Since the current SDK is missing this control I have found myself asking the question…

  CustomControl or UserControl?

So, what is the main difference and what should we use?!


UserControl: Provides a simple way to create a control.

CustomControl: Represents the base class for user interface (UI) elements that use a ControlTemplate to define their appearance.

So, now we can see that the main difference between them is that the CustomControl basically build by using the ControlTemplate.
The big and the major advantage that we have during XAML design (and this is true to both control types) is that we can change the style of an existing control while the logic functionality remain as it is. Change the style, Not the logic!!! Still, what is the difference ???

The big issue here is how easy we can change the style!!!

If there is something that I don’t like is to change all the control or try to find it’s inner controls to change it. For example if we have a ComboBox and I want to change the Path of the triangle on the button, I want an easy way to do so. Today we can use the Expression Blend ability to auto extract and edit the control style.


When you creation a UserControl by auto generated <Style> it abstract and give us the main layer and noting beside that

For example – The <Style> will look like similar to that:


We have nothing to start with!!!


On the Other hand the CustomControl is based on the ControlTemplate and therefore, also the auto generated tool can base on it and the <Style> will be more detailed. So the change that we would like to do can  be more specific.


if you need an atomic control and the ability to change the style in the future, we should use the CustomControl (don’t forget to override OnApplyTemplate() method). If the control is more complex  just create a UserControl and hope that his style is final and no change should be done later.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


one comment

  1. SpillmanAugust 5, 2012 ב 15:35

    For newest news you have to pay a quick visit world-wide-web and on world-wide-web
    I found this web page as a finest web site for most recent updates.