Respecting the Target Control’s Properties

There’s a bit of a problem with custom template in Figure 17.5. 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 17.5 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. Although data binding is covered in the next chapter, its use in ...

Get Universal Windows® Apps with XAML and C# 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.