What is Style Inheritance?

 Posted by Ddd on 2/24/2011 | Category: WPF Interview questions | Views: 4477 | Points: 40

It is the technique through which one style aquires the features of another style

It is implemented through BasedOn property of the Style class.

<Window x:Class="WpfApplication14jan.Window1"

Title="Window1" Height="300" Width="300">
<Style x:Key="One" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="Green"/>
<!-- This is how the style inheritance is implemented-->
<Style x:Key="Two" BasedOn="{StaticResource One}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Yellow"/>
<Button Height="100" Width="100" Style="{StaticResource Two}" Content="Welcome">

//When you run the WPF Form, the Button will aquire the Formatting from both the

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Tripati_tutu on: 2/26/2011 | Points: 10
Nice one.

Login to post response