我正在尝试使用Pack URI使我的应用程序(WPF)使用我的App.xaml中的引用程序集。在我的解决方案中,我有几个项目。在基本应用程序中,我只有我的App.xaml。我希望这个程序集使用引用程序集。
使用App.xaml项目1调用我的基础项目(在解决方案中)。这是App.xaml的相关部分:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MyProject.Project2;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>项目2有一个带有Generic.xaml的文件夹“主题”。我确信我做的包URI是错误的,因为没有使用Generic.xaml中的样式(我正在用一个自定义窗口覆盖默认窗口,但它目前无法工作。应用程序显示默认窗口样式,窗口中的所有内容都是黑色的)。
文件夹层次结构:
MainFolder
Project 1
App.xaml
bin
Debug
Application.exe
Project 2
Themes
Generic.xaml问题:
pack://application:,,,语法吗?这一切意味着什么?提前谢谢。
发布于 2012-11-15 16:16:14
弄明白了。在MyProject.Project2中,我需要AssemblyInfo.cs中的以下代码:
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]发布于 2012-11-14 17:13:25
包Uri后面的第一项是程序集的名称。确保你设置了:
"pack://application:,,,/[ASSEMBLY name here];component/Themes/Generic.xaml"
发布于 2012-11-15 14:09:53
尝试将资源字典移到项目2中而不是在App.xaml中。
https://stackoverflow.com/questions/13382345
复制相似问题