Skip to content

Instantly share code, notes, and snippets.

@mathieubrun
Last active December 12, 2015 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathieubrun/4702765 to your computer and use it in GitHub Desktop.
Save mathieubrun/4702765 to your computer and use it in GitHub Desktop.
Inherit defaut wpf style
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Background" Value="Red" />
</Style>
<Style TargetType="TextBlock" x:Key="Custom1">
<Setter Property="Foreground" Value="Blue" />
</Style>
<Style TargetType="TextBlock" x:Key="Custom2" BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="Foreground" Value="Blue" />
</Style>
</StackPanel.Resources>
<TextBlock>Defaut</TextBlock>
<TextBlock Style="{StaticResource Custom1}">Custom 1 : background remis par defaut</TextBlock>
<TextBlock Style="{StaticResource Custom2}">Custom 2 : background repris de Default</TextBlock>
</StackPanel>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment