0
<Window.Resources>
<Style x:Key="Style_1" TargetType="{x:Type Button}">
    <Setter Property="Background" Value="Green"/>
</Style>
<Style x:Key="Style_2" TargetType="{x:Type Button}">
    <Setter Property="Foreground" Value="White"/>
</Style>
<Style x:Key="Style_3" TargetType="{x:Type Button}">
    <Setter Property="BorderBrush" Value="Red"/>
</Style>

<Grid x:Name="LayoutRoot">
    <Button Content="MultyStyles" Margin="160,136,248,222"/>

Now i want to apply Above Three Style into one control.I can apply two style to one Controle like below.

<Window.Resources>
<Style x:Key="Style_1" TargetType="{x:Type Button}">
    <Setter Property="Background" Value="Green"/>
</Style>
<Style x:Key="Style_2" TargetType="{x:Type Button}" BasedOn="{StaticResource Style_1}">
    <Setter Property="Foreground" Value="White"/>
</Style>
<Style x:Key="Style_3" TargetType="{x:Type Button}">
    <Setter Property="BorderBrush" Value="Red"/>
</Style>

<Grid x:Name="LayoutRoot">
    <Button Content="MultyStyles" Margin="160,136,248,222" Style="{StaticResource Style_2}"/>
</Grid>

But i don't know to apply more than two style to one control. what should i do for that ?

CHANDRA
  • 4,778
  • 8
  • 32
  • 51

1 Answers1

0

You can only do this using the BasedOn logic you've already used. As an option, you can use Triggers to change the style if it makes sense in your project.

Big Daddy
  • 5,160
  • 5
  • 46
  • 76