0

Possible Duplicate:
How to apply multiple styles in WPF

<Window.Resources>   
    <Style TargetType="Button" x:Key="style_1">
        <Setter Property="Foreground" Value="Green" />
    </Style>
    <Style TargetType="Button" x:Key="style_2">
        <Setter Property="Background" Value="Blue" />
    </Style>    
</Window.Resources>


    <Button x:Name="btn_1" Content="Button" HorizontalAlignment="Left" Height="40" Margin="153,95,0,0" VerticalAlignment="Top" Width="89" Style="{StaticResource style_1}" Click="Button_Click" />
    <Button x:Name="btn_2" Content="Button" Height="40" Margin="281,95,262,0" VerticalAlignment="Top" Style="{StaticResource style_2}"/>

Now i want to apply style_1 and style_2 to btn_1 what should i do for that.

Community
  • 1
  • 1
ASHOK A
  • 1,966
  • 3
  • 17
  • 31

1 Answers1

0

You cannot apply two styles to a single control in XAML.

What you could do, is letting style_2 inherit from style_1 by specifying

<Style TargetType="Button" x:Key="style_2" BasedOn="{StaticResource style_1}"> 
    <Setter Property="Background" Value="Blue" />
</Style>

and then use only style_2.

Jens
  • 25,229
  • 9
  • 75
  • 117