如何在StaticResource(uwp)中使用Multiple属性?

时间:2016-05-02 13:04:54

标签: xaml win-universal-app uwp-xaml

如何在Style =“{StaticResource

>中使用多个键(在ResourceDictionary中使用)

TopHeader}“

1 个答案:

答案 0 :(得分:1)

您可以在新创建的样式中组合多个样式。 例如:

    <Style x:Key="Style1" TargetType="Button">
        <Setter Property="Background" Value="Yellow" />
    </Style>
    <Style x:Key="Style2" TargetType="Button">
        <Setter Property="Foreground" Value="Red" />
    </Style>
    <Style x:Key="Style1Style2" TargetType="Button">
        <Setter Property="Background" Value="Yellow" />
        <Setter Property="Foreground" Value="Red" />
    </Style>

或者您可以创建BasedOn样式:

   <Style x:Key="Style3" TargetType="Button" BasedOn="{StaticResource Style2}">
        <Setter Property="Background" Value="Yellow" />
    </Style>