Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

20. Resources > Style Hierarchies

Style Hierarchies

In the solution to the last exercise, I created two different styles for the Label elements, and pointed out that there was a lot of duplication. The Style.BasedOn property lets you avoid the duplication:

Instead Of

<Style x:Key="BasicLabel" TargetType="Label">
 <Setter Property="Margin" Value="5" />
 <Setter Property="HorizontalAlignment" Value="Right" />
 <Setter Property="VerticalAlignment" Value="Center" />
 <Setter Property="FontWeight" Value="Black" />
</Style>

<Style x:Key="RequiredLabel" TargetType="Label">
 <Setter Property="Margin" Value="5" />
 <Setter Property="HorizontalAlignment" Value="Right" />
 <Setter Property="VerticalAlignment" Value="Center" />
 <Setter Property="FontWeight" Value="Black" />
 <Setter Property="Label.Foreground" Value="Chocolate" />
</Style>


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


 Â