2012-07-31 6 views
0

가능한 중복 : wpf에서 단일 컨트롤에 multy 스타일을 적용하는 방법은 무엇입니까?

<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}"/> 


How to apply multiple styles in WPF

지금 내가 그것을 위해 무엇을해야 btn_1을에 style_1 및 style_2을 적용 할.

답변

0

XAML의 단일 컨트롤에 두 가지 스타일을 적용 할 수 없습니다.

당신이 무엇을 할 수 있는지,시키는됩니다 style_2는

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

를 지정하여 style_1에서 상속 만 style_2을 사용합니다.

관련 문제