Respecting the Target Control’s Properties
There’s a bit of a problem with the custom template in Figure 18.4. Any Button
it is applied to will look the same, no matter what the values of its properties are. Most notably, the right Button
in Figure 18.4 has "With Custom Template"
as its content, but it never gets displayed. If you’re creating a control template that’s meant to be broadly reusable, you need to do some work to respect various properties of the target control (sometimes called the templated parent).
Respecting ContentControl’s Content Property
The key to inserting property values from the target element inside a control template is a specialized form of data binding. You can set a property to the markup extension value:
{TemplateBinding ...
Get XAML Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.