Introduction
In WPF, Microsoft provides some basic controls, but the work of these basic controls often does not meet our needs, this time we need to develop their own control according to the actual needs, but it is important to note that not all features are not satisfied with the needs of the custom control to implement. In fact, once a custom control is used, the style,datatemplate,controltemplate features provided by WPF do not meet our needs.
Introduction to Custom Controls
Inherited parent Type |
Advantages |
Disadvantages |
UserControl |
As simple as creating a normal WPF interface, you can use events directly No need to support complex user customizations |
Only existing controls can be used
|
Control |
Users can customize an appearance through ControlTemplate The control can support different topics (Theme) Ensure UI and logic (logic) detach with commands and binding instead of events, and avoid using directly referencing UI elements in ControlTemplate |
Need to implement support for complex user customizations |
FrameworkElement |
Finer control over the previous two appearance of controls You can customize the appearance of the render logic (render) control.
|
|
Basic steps for customizing controls
Summarize
Reference
Control Customization
[WPF] ListView click the column header sorting feature to implement
WPF Series Custom Controls