Customizing a default template of custom control
Custom controls provide default control templates so that they have some look if used as is. However, the real power of custom controls is the ability to change the template without harming any functionality. In this recipe, we'll change the template for our color picker control to get a different look with the same functionality without writing any code – just a different control template.
Getting ready
Open the CH10.TestCustomControls
project. We'll use that project to create the new template and compare it to the default one.
How to do it...
We'll create a different control template that utilizes just some of the capabilities of the color picker control and makes sure the control is tolerant of missing pieces.
Open
App.xaml
.Add a
ControlTemplate
resource that builds an alternative look for a color picker. Notice thepart names:<ControlTemplate x:Key="cpTemplate"> <Grid> <Grid.ColumnDefinitions> <...