Customizing the template of a custom control
The development of a custom control always requires its default template to be changed to give it a proper look and make it ready for theming support. That starts with the customization of the template and its default values.
In this recipe, we will learn how to change the template and use TemplateBinding
to create a relation with its property values.
Getting ready
To get started, launch Visual Studio, create a project, and add a new custom control in it. For this demonstration, we will be using the existing project, CH05.SearchControlDemo
, that we created in the previous recipe. So, let's open the project.
How to do it...
As we want to customize the template of the custom control to have a proper template binding, perform the following steps:
- Open the
Generic.xaml
file, which is present under theThemes
folder of the project. - Now, scroll down to the definition of the
ControlTemplate
as we need to customize the look and feel of it. - Search for the
TextBox...