The great North American Cold Wave has retreated, and our man is back! In this video tutorial Robert Evans walks you through creating a shared style and using Blend together with Visual Studio 2013 to create Implicit and Explicit Styles. He also shows you how to use the new ThemedResource introduced in Windows 8.1.


If you are coming from WPF or Silverlight background, the Windows Runtime doesn't support Binding usage for Setter Values, nor Behaviors, however it does support Styles. You can use styles to set visual properties and factor them out into reusable resources. Styles can be defined inline in the XAML, in an individual XAML page's resources, in the App.xaml file, or if it is shareable in a separate resource dictionary XAML file.

Styles

Styles can be Implicit or Explicit. If you don't have the x:Key attribute and you've just defined the TargetType for the Style it is "Implicit", otherwise Explicit. The TargetType string specifies a FrameworkElement type that the style will apply to. So long as they target the same type of control you can use the BasedOn property to create inherited styles.

Theme Dictionary

This is a type of merged dictionary for resources that vary depending on which theme a is currently being used. The XAML parser only creates the resources when they're specifically requested by XAML resource references when the app first starts any resource reference made by a ThemeResource reference is evaluated based on the theme used and re-evaluated even at runtime every time the user changes the theme.

A quick note: when defining your ThemeResource XAML, it is important not to attempt to make a forward reference to a resource that is defined further on in your the XAML file. Depending on the usage this will either fail with an error or incur significant performance issues.

That’s it for now! You can read more here: ThemedResource and Resource Dictionary. See you soon!


Original content from Robert Evans; posted by MSPFE editor from sunny India – Arvind Shyamsundar.