Setting Template Inside a Style

It’s worth emphasizing why setting the Template property inside a Style is so powerful. It has two important advantages:

It gives you the effect of default templates when combined with an implicit Style, as leveraged in Listing 17.1. Independent of this, there is no such thing as a default control template.

It enables you to provide default yet overridable property values that control the look of the template. In other words, it enables you to respect the templated parent’s properties but still provide your own default values.

The final point is important. When Listing 17.1 changed the custom template’s top gradient color from a hard-coded Blue to pick up the Button’s Background.Color, the default value became ...

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.