XAML - Use BasedOn property to perfom style inheritance

By [)ia6l0 iii

You can use the "BasedOn" property of a Style to inherit another style on a style. See the following example.

<Style TargetType="TextBlock" x:Key="Default">
        <Setter Property="
Foreground" Value=""Green" />
</Style>
<Style TargetType=
"TextBock" x:Key="Modified" BasedOn="{StaticResource Default}" />
        <Setter Property="
FontSize"" Value="8" />
</Style>

So if we apply the Modified style to a textblock, the Default style would also get applied.

Related FAQs

The UIElement.Visibility enumeration provides the Visible, Collapsed and Hidden enumeration values.
A Pseudo class is a class that applies to an element due to the result of an user's action; Hover for example.
A Rule set in css refers to a selector and its declarations.
Use the DataObject's Pasting handler to avoid pasting text into a textbox
Use the DataObject's Copying handler to avoid copying text from a textbox
Use the Source and the LoadedBehavior properties of the MediaElement.
XAML - Use BasedOn property to perfom style inheritance  (1449 Views)