July 2017
Beginner
466 pages
9h 37m
English
Just like class inheritance, you can also inherit a style from another base style by using the property BasedOn. This reduces duplicate style setters and gives you a clean, easy-to-maintain code.
Let us create one base Style for button control having only two setters to change its background and foreground color. As we are going to inherit this style, let's give it the name ButtonBaseStyle by defining the x:Key attribute:
<Style x:Key="ButtonBaseStyle" TargetType="Button">
<Setter Property="Background" Value="Orange"/>
<Setter Property="Foreground" Value="White"/>
</Style>
Create another style with two more setters to define the button's height and width properties. Now inherit the first style by setting ...
Read now
Unlock full access