Live Chat Icon For mobile
Live Chat Icon

How can I create a Style deriving from another Style

Platform: WPF| Category: Styles and Templates

Perhaps you want your two ‘TextBlock’ elements to share some property values such as the FontFamily and the centered HorizontalAlignment, but you also want the text ‘My Pictures’ to have some additional properties. You can do that by creating a new style that is based on the first style, as shown here.




<!--A Style that extends the previous MyBaseStyle Style-->
<!--This is a 'named style' with an x:Key of MyDerivedStyle-->
<Style BasedOn='{StaticResource {x:Type MyBaseStyle}}'
  <Setter Property='FontSize' Value='26'/>
  <Setter Property='Foreground'>
      <LinearGradientBrush StartPoint='0.5,0' EndPoint='0.5,1'>
          <GradientStop Offset='0.0' Color='#90DDDD' />
          <GradientStop Offset='1.0' Color='#5BFFFF' />

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.