Skip to content

Custom Controls

In contrast to UserControl (contained in namespace System.Windows.Controls) there is no distinct base class for a custom control. Actually, a custom control is a derivation of any WPF control. For example a Button, Grid, ContentControl, Control, FrameworkElement or any other type. You need to choose your base class depending on the base functionality you need.

A custom control only consists of code. Its view is defined by so called control templates (not to be mistaken by data templates). This concept is a very powerful feature as you can change the appearance of any control in wpf (including your custom controls which are also just simple controls) by adding your own control template. For example, you can change the appearance of a wpf button to display a circular button by simply replacing the control template without thinking about the implementation of the button.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright (c) by Thomas Kemp, 2021