#1,177 – UIElement vs. FrameworkElement vs. Control
October 10, 2014 Leave a comment
If you want to implement a custom element in WPF, either to display something in a user interface or to get input from a user, you’ll typically derive your custom element from one of the following classes: UIElement, FrameworkElement, or Control.
The inheritance chain for these three classes is:
When creating a custom control, you’ll want to choose as a base class whichever one of these classes has only the features that you want. The core functionality for these three classes is:
- UIElement (Layout + Input + Focus + Events)
- Layout behavior (parent/child relationship, measure/arrange passes)
- Responding to user input (input events, command bindings)
- Managing focus
- Raising and responding to routed events
- FrameworkElement adds
- Alignment-related and Margin properties
- Animation support
- Data binding
- Data templates
- Styles
- Defaults Focusable to false
- Control adds
- Control templates
- Background, Foreground
- Font-related properties
- Border-related properties
- Defaults Focusable to true