C# 加载资源字典时出错
我已经看过并尝试了我找到的这些,甚至复制了。然而,我仍然无法找到有效的解决方案 XAML:C# 加载资源字典时出错,c#,wpf,telerik,C#,Wpf,Telerik,我已经看过并尝试了我找到的这些,甚至复制了。然而,我仍然无法找到有效的解决方案 XAML: 根据Telerik的文档,我知道的第一件事是错误的,必须补充一点 它们可以合并到应用程序的资源中(在App.xaml中),因此将隐式应用到任何没有本地样式集的控件上。例如,如果需要从Telerik.Windows.Controls.dll设置控件样式,则需要Telerik.Windows.Controls.xaml资源字典 也就是说,对于数据可视化,您缺少了资源字典。如果这不能解决问题,继续阅读 我记得上
根据Telerik的文档,我知道的第一件事是错误的,必须补充一点 它们可以合并到应用程序的资源中(在App.xaml中),因此将隐式应用到任何没有本地样式集的控件上。例如,如果需要从Telerik.Windows.Controls.dll设置控件样式,则需要Telerik.Windows.Controls.xaml资源字典 也就是说,对于
数据可视化
,您缺少了资源字典
。如果这不能解决问题,继续阅读
我记得上一次,当我使用Telerik查看我的应用程序的主题时,有两种不同的方法可以应用样式,正确地应用样式一开始可能有点棘手。有隐式样式(NoXaml)和标准样式,其中样式内置于控件库中。隐式样式是以“全局”方式设计应用程序样式的推荐方法。IIRC,它的性能也更高,代码更干净
因为我们在WPF聊天中讨论过,所以听起来您不确定要从源代码构建哪些二进制文件。隐式样式要求您构建Binaries.NoXaml源代码。在这之后,您必须确保添加了对来自。\Binaries.NoXaml\WPF4x\
目录的正确程序集的引用
上次我从源代码构建时,构建说明包含在下载的.ZIP文件中。确保您仔细遵守这些说明。我没有使用内置的VisualStudioTelerik工具来构建/部署我的参考库,所以如果您使用了,那么手动可能是一种方法
还有几件事。我怀疑构建没有成功完成。你的Telerik参考资料上的版本应该不是0.0.0.0
。其次,如果我没记错的话,我在定义源代码以及可能的顺序问题上遇到了问题——因此请尝试我在下面的示例中使用的源代码,并可能将NotifyIconResources.xaml
移到Telerik声明下面
下面是我的XAML与隐式样式技术一起使用:
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/System.Windows.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Input.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
和往常一样,启动一个新项目并获得像这样的基本功能可能会让你感到惊奇,而且它也会阻止你在当前代码库中更改太多东西,以至于你最终忘记了已经更改的东西,并在你不想要的地方引发问题
System.Windows.Markup.XamlParseException was unhandled
HResult=-2146233087
Message='Cannot create unknown type '{clr-namespace:Telerik.Windows.Controls.External}Windows8ThemeExternal'.' Line number '15' and line position '6'.
Source=PresentationFramework
LineNumber=15
LinePosition=6
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at MyApp.App.InitializeComponent() in App.xaml: line 1
at MyApp.App.Main() in c:\MyApp\obj\Debug\App.g.cs: line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Xaml.XamlObjectWriterException
HResult=-2146233088
Message='Cannot create unknown type '{clr-namespace:Telerik.Windows.Controls.External}Windows8ThemeExternal'.' Line number '15' and line position '6'.
Source=System.Xaml
LineNumber=15
LinePosition=6
StackTrace:
at System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType)
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
InnerException:
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/System.Windows.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Input.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />