Skip to content

Instantly share code, notes, and snippets.

@thlorenz
Created October 23, 2010 00:54
Show Gist options
  • Save thlorenz/641622 to your computer and use it in GitHub Desktop.
Save thlorenz/641622 to your computer and use it in GitHub Desktop.
Shows a way to inherit styles and add to it in WPF
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Blue"/>
</Style>
</Grid.Resources>
<Border
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Gray"
BorderThickness="2"
CornerRadius="2">
<Border.Resources>
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="White"/>
</Style>
</Border.Resources>
<StackPanel>
<StackPanel.Resources>
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="{x:Type Button}">
<Setter Property="FontStyle" Value="Italic"/>
</Style>
</StackPanel.Resources>
<Button Content="Click the Waterfall"/>
</StackPanel>
</Border>
</Grid>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment