How to Implement Style Inheritance in Windows Phone 8 ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

There are times when you want to apply some styles to a control in Windows Phone 8 but you may not want to start it from scratch . In these scenarios , the developers can use the property “BasedOn” to reference another style that is defined .

For example , assume that there is already a style named “Style1” and for the Style2 you might want to inherit from Style1 . Below is a sample code snippet that demonstrates how one can do that.

How to Implement Style Inheritance in Windows Phone 8 ?

<Style x:Key="Style1" TargetType="TextBlock">
   <Setter Property="FontSize" Value="8" />
</Style>
<Style x:Key="Style2" BasedOn="{StaticResource Style1}" TargetType="TextBlock">
   <Setter Property="Foreground" Value="Aqua" />
</Style>
Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: