Once the project has been opened, perform the following steps to create a dependency property named SearchTerm and bind it with the control UI:
- Let's open the SearchControl.cs to create a dependency property. Inside the class definition, type propdp and press the TAB key twice to create the property structure. By default, it generates MyProperty of type int.
- Change the property type from int to string and press TAB.
- Rename MyProperty to SearchTerm and press TAB again.
- Now change ownerclass to SearchControl and press TAB.
- Pass string.Empty as the default value to the PropertyMetaData.
- Once these preceding steps are done, your property is ready to use. Now open the Generic.xaml page to create the binding to the UI control.
- Inside the template of the control, find the TextBox named PART_TextBox.
- Now, add the Text property to it, by using TemplateBinding. You will see the dependency property (SearchTerm) listed in the XAML IntelliSense, as shown here:
- Let&apos...