我正在尝试使用该语句动态添加xaml资源文件,
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("resources/leaf_styles.xaml", UriKind.Relative) });
Run Code Online (Sandbox Code Playgroud)
这是抛出异常,无法找到资源'resources/leaf_styles.xaml'.
我将leaf_styles.xaml文件添加到资源文件夹下的项目中,BuildAction设置为"Content",CopyAlways设置为True.我仍然得到这个错误.有人可以帮我指出什么错?
附加信息 -
如果我把它作为绝对位置,它正常工作.
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(@"D:\foo\trunk\bin\resources\leaf_styles.xaml", UriKind.Absolute) });
Run Code Online (Sandbox Code Playgroud) 在WPF中,是否有一种方法可以枚举特定嵌入式资源目录中的所有文件?也就是说,所有项目的目录都具有设置为"资源"的"构建动作".