15.11. Styles

Styles in Silverlight 3.0 can now be modified at runtime and support inheritance.

15.11.1. Applying Styles Dynamically

The following code shows how to apply a style to a button at runtime:

myButton.Style=(Style)Application.Current.Resources["MyHorridFuchsiaStyle"];

15.11.2. Style Inheritance

Silverlight 3.0 allows you to create styles that inherit from another style (sort of like CSS) by specifying a parent style in the BasedOn property. The following code creates a style inheriting from MyHorridFuchsiaStyle:

<Style x:Key="HybridStyle" TargetType="Button"
BasedOn="{StaticResource MyHorridFuchsiaStyle}"></Style>

15.11.3. Merge Dictionary Support

It is now possible to refer to external resource dictionary files within your application:

<ResourceDictionary>
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="myExternalResources.xaml" />
  </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.201.52