如何在具有文件夹结构的 WPF 中提供 ResourceDictionary Source
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21617104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to give ResourceDictionary Source in WPF with folder structure
提问by Jeevan
In a WPF application, Resources.xaml(Resource Dictionary) is placed in Resources folder and GetStarted.xaml(UserCOntrol) is placed in Views folder. Wizard.xaml(UserControl) is in the root folder.
在 WPF 应用程序中,Resources.xaml(Resource Dictionary) 放置在 Resources 文件夹中,GetStarted.xaml(UserCOntrol) 放置在 Views 文件夹中。Wizard.xaml(UserControl) 位于根文件夹中。
Now, in Wizard.xaml:
现在,在 Wizard.xaml 中:
<ResourceDictionary.MergedDictionaries>
<ResousrceDictionary Source="Resources/Resources.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
works fine.
工作正常。
I'm not sure how to access it In GetStarted.xaml,
我不确定如何在 GetStarted.xaml 中访问它,
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="component/Resources/Resources.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
doesn't work.
不起作用。
Please help me. I'm new to WPF.
请帮我。我是 WPF 的新手。
回答by Mukesh Rawat
Try AssemblyTitle in your source like below:
在您的源代码中尝试 AssemblyTitle,如下所示:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/YourProjectAssemblyTitle;component/Resources/Resources.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>

