[英]StaticResource where resource is in external assembly?
Basically, I want to keep all my XAML resources in an external assembly (for my styles). 基本上,我想将所有XAML资源保存在外部程序集中(对于我的样式)。 I have a reference of this external assembly in my application.
我在我的应用程序中引用了这个外部程序集。
Is there something to do with satellite assemblies or whatnot or how do I go about accessing these styles so that my application can still have StaticResource tags without compilation errors? 有没有关于附属程序集或诸如此类的内容或如何访问这些样式,以便我的应用程序仍然可以具有StaticResource标记而没有编译错误?
Assuming you keep your styles in a ResourceDictionary
in the other assembly, you just need to merge it with your current resources (whether they are on a Window
or UserControl
or whatever). 假设您将样式保存在另一个程序集中的
ResourceDictionary
中,您只需将其与当前资源合并(无论它们是在Window
还是UserControl
上等)。
If we assume that 如果我们假设
ResourceDictionary
is under the namespace Resources; ResourceDictionary
位于命名空间Resources下; and ...then you can merge the dictionaries as below: ...然后你可以合并下面的字典:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="pack://application:,,,/external.assembly.name;component/Resources/MyStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- other resources go here -->
</ResourceDictionary>
</UserControl.Resources>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.