Wpf 在UserControl上/中设置样式而不必定义MergeDictionary?

Wpf 在UserControl上/中设置样式而不必定义MergeDictionary?,wpf,Wpf,我希望在项目树基础上的资源字典中保存的一些用户控件上设置样式。我发现的唯一方法是在下面的参考资料中定义MergeDictionary,以链接xaml文件中的样式。不过,我不希望在需要这种样式的每个控件上都使用相同的代码。有更好的方法吗 <UserControl x:Class="TestApp.Screens.Sub.Details" ... Style="{DynamicResource BottomContentUserControl}"> &l

我希望在项目树基础上的资源字典中保存的一些用户控件上设置样式。我发现的唯一方法是在下面的参考资料中定义MergeDictionary,以链接xaml文件中的样式。不过,我不希望在需要这种样式的每个控件上都使用相同的代码。有更好的方法吗

<UserControl
    x:Class="TestApp.Screens.Sub.Details"
    ...
    Style="{DynamicResource BottomContentUserControl}">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../GeneralStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
</UserControl>

您可以将样式添加到ApplicationResourceDictionary,也可以将它们添加到App.xaml文件中,以便在整个应用程序中应用它们