如何在Phone类库项目中添加ResourceDictionary并访问 [英] How to add ResourceDictionary in Phone class library project and access it
问题描述
我正在处理一个项目,我有一个引用库项目的子项目.
I am working on a project where i have child project which is referencing the library project.
在我的库项目(电话类库)中,我如何创建 ResourceDictionary.xaml,我需要在其中添加一些样式并在 xaml 文件和 .cs 文件中使用它.
In my Library project(Phone class library) how do i create ResourceDictionary.xaml where i need to add some styles and use it in xaml files and as well as .cs files.
我需要在我的 xaml 文件和 .cs 文件中访问 ResourceDictionary.xaml 中的样式,该怎么做?
I need to access styles in ResourceDictionary.xaml in my xaml files as well as .cs files how to do it ?
推荐答案
在根文件夹中创建一个文件夹为 Generic
并将您的资源文件放在那里...
Create a folder as Generic
in the root folder and have your resource files there...
在 XAML 中访问它
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
或
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AssembleName;component/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
在 .cs 中访问它
new URI(pack://application:,,,/AssembleName;component/Generic.xaml)
这篇关于如何在Phone类库项目中添加ResourceDictionary并访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!