The importance of dependency properties in WPF programming is well known, and the concept is not outlined or explained here. Detailed introduction to view blog.csdn.net/rabbitsoft_1987/article/details/18240171. This article explains how to define a simple dependency attribute. The implementation function is to customize MyLabel, add Caption dependent property, the content is displayed as Caption value, and bind the Caption property of MyLabel to the Text content of TextBox. When the Text changes, the content of MyLabel will be modified.
Platforms Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server
2008 (Server core not supported), Windows Server 2008 R2 (Server core SP1 or later supported), Windows Server 2003
.NET version.NET Framework Supported by the following versions: 4, 3.5, 3.0.NET Framework Client Profile Supported by the following versions: 4, 3.5 SP1
Creating a MyLabel control adds the Caption dependency property to the MyLabel control, binding the Content of the Label control to the newly defined Caption dependency property. ps: Typing propdp in the background code (*.cs) and then Tab will create the dependency property definition template.
Use the MyLabel control to bind the Caption property of the MyLabel control to the Text property of the text box.
This page is based on experience