Defining a style as a resource

A style can be defined in two ways: implicit styling and explicit styling. In implicit styling definition, you need to specify a TargetType for that style and all the controls defined by TargetType within that context will automatically use that specified style. The explicit style definition has an x:Key attribute along with the TargetType attribute and will apply it only to that target in the context which has explicitly referenced the resource as its style with the markup extension {StaticResource}.

Here is an implicit style definition of a button:

  <Style TargetType="Button"> 
     . 
     . 
     . 
  </style> 

Here is an explicit style definition of a button, having a key named MyButtonStyle that can be attached to a button ...

Get Mastering Visual Studio 2017 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.