【发布时间】:2012-10-19 11:07:05
【问题描述】:
我希望在一个独立的 dll 中包含一组样式,这些样式可以从许多不同的 WOF 类中引用来定义常见的样式。
我创建了独立的 dll 并尝试引用它,但遇到了问题。
这是独立 dll 的代码:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="myStyle" TargetType="Button">
<Setter Property="Background" Value="Orange" />
<Setter Property="FontStyle" Value="Italic" />
<Setter Property="Padding" Value="8,4" />
<Setter Property="Margin" Value="4" />
</Style>
<!-- store here your styles -->
</ResourceDictionary>
这是我试图引用它的地方:
<src:GX3ClientPlugin.Resources>
<ResourceDictionary Source="pack://application:,,,/GX3StyleResources.dll;component/GX3StyleResources.xaml" />
</src:GX3ClientPlugin.Resources>
运行时出现以下异常:
无法加载文件或程序集“GX3StyleResources.dll,Culture=neutral”或其依赖项之一。系统找不到 指定的文件。
有什么想法吗?
【问题讨论】:
-
根据我的经验,如果您将资源、图像等保存在不同的项目中,则很难管理。我也认为它没有任何好处。
标签: c# wpf .net-assembly resourcedictionary