Implicit Styles
Unlike other objects placed in a Resources
collection, you can omit the x:Key
and x:Name
from a Style
! If you do this, the target type of the Style
(for example, typeof(Button)
) is used as the key in the ResourceDictionary
. This is handy, because it causes the Style
to be implicitly applied to all elements of that target type within the same scope. This is typically called a typed style or implicit style as opposed to a named style.
The scope of a typed Style
is determined by the location of the Style
resource. For example, it would implicitly apply to all relevant elements in a Page
if it’s added to the Page
’s Resources
collection or all relevant elements in the app if it’s added to Application
’s Resources
collection. The following ...
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.