WPF Style基于App.xaml中的ResourceDictionary

时间:2017-06-01 21:34:22

标签: c# wpf xaml resourcedictionary

我使用了ResourceDictionaryApp.xaml中定义的样式预设:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

我现在想要的是能够在另一个xaml 中设置新样式,该样式不应该覆盖我App.xaml的设置。

这应该类似于:

<Grid.Resources>
    <Style TargetType="Button" BasedOn=".....">
        <Setter Property="Margin" Value="0,0,5,0"></Setter>
    </Style>
</Grid.Resources>

问题是我无法弄清楚我需要在BasedOn元素中写什么。

有人能告诉我一个简单的方法吗?

1 个答案:

答案 0 :(得分:1)

如果您希望将样式基于默认的Button样式:

,请尝试此操作
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
...
相关问题