WPF运行报错System.Windows.Markup.XamlParseException:““在“System.Windows.StaticResourceExtension”

报错信息

System.Windows.Markup.XamlParseException:““在“System.Windows.StaticResourceExtension”上提供值时引发了异常。”,行号为“42”,行位置为“40”。

根据报错信息检查到报错的位置,发现在UI页面写错了控件的Style值

<Label Content="中文名称:" Style="{StaticResource RightContentLabel}" />

改正过来即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Hello WPF WPF培训教程全文共30页,当前为第1页。 Windows Form A new event model Can create control Still based on GDI+ Wrapper of Win32 WPF培训教程全文共30页,当前为第2页。 WPF WPF use DirectX to draw WPF's UI is based vector Markup Language Programming WPF培训教程全文共30页,当前为第3页。 WPF And .NET Framework CLR Base Class Library(BCL) Windows Forms ASP.NET ADO.NET WCF WPF WF WCS .NET Framework 2.0 .NET Framework 3.0 WPF培训教程全文共30页,当前为第4页。 WPF Is A Platform OS .NET Framework WPF Engine Business Logic Event Manager Renner Engine Property Manager WPF培训教程全文共30页,当前为第5页。 WPF & Win32 WPF Engine Windows32 GDI WPF培训教程全文共30页,当前为第6页。 One Simple Example C# XAML WPF培训教程全文共30页,当前为第7页。 Translate XAML To C# <Button x:name="ButtonOK">OK</Button> Button buttonOK = new Button(); buttonOK.Content = "OK"; XAML C# Translate WPF培训教程全文共30页,当前为第8页。 XAML Exist AS Resource Resource Code Assembly WPF培训教程全文共30页,当前为第9页。 Markup Extension <Button x:name="ButtonOK" Hiehgt="25">OK</Button> <Button x:name="ButtonOK" Hiehgt="{x:static SystemParameters.IconHeight}">OK</Button> Markup Extension WPF培训教程全文共30页,当前为第10页。 Create Ourself Markup Extension WPF培训教程全文共30页,当前为第11页。 Dependency Property WPF培训教程全文共30页,当前为第12页。 Common C# Class myDefault = 1 dog1 myDefault = 3 dog2 myDefault = 3 dog3 WPF培训教程全文共30页,当前为第13页。 Dependency Property MyDefault dog1 MyDefault dog2 MyDefault dog3 MyDefault Instance pointer 1 dog1 3 dog2 3 dog3 … … … … WPF Engine WPF培训教程全文共30页,当前为第14页。 Attached Property DockPanel Class Define Dock Instance pointer Left buttonLeft Top buttonTop Right buttonRight Bottom buttonBottom … … WPF Engine WPF培训教程全文共30页,当前为第15页。 Button RoutedEvent ButtonChrome ContentPresenter TextBlock Event WPF培训教程全文共30页,当前为第16页。 WPF Controls Content Control Items Control Rang Control Text Control WPF培训教程全文共30页,当前为第17页。 UI Layout Canvas StackPanel DockPanel WrapPanel Grid WPF培训教程全文共30页,当前为第18页。 Binary Resource WPF培训教程全文共30页,当前为第19页。 Logic Resource Logic resource is a dictionary Every element can have logic resource There is a logic route algorithm WPF培训教程全文共30页,当前
【原 书 名】 Windows Presentation Foundation Unleashed <br>【原出版社】 Sams <br>【作 者】Adam Nathan [同作者作品] <br>【丛 书 名】 英文原版系列图书 <br>【出 版 社】 Sams<br>【书 号】 0672328917 <br>【出版日期】 2006 年12月 <br>【开 本】 16开 <br>【页 码】 656 <br>【版 次】1-1 <br>Book Description<br><br> <br><br>Printed entirely in color, with helpful figures and syntax coloring to make code samples appear as they do in Visual Studio.<br><br> <br><br>Windows Presentation Foundation (WPF) is a key component of the .NET Framework 3.0, giving you the power to create richer and more compelling applications than you dreamed possible. Whether you want to develop traditional user interfaces or integrate 3D graphics, audio/video, animation, dynamic skinning, rich document support, speech recognition, or more, WPF enables you to do so in a seamless, resolution-independent manner. Windows Presentation Foundation Unleashed is the authoritative book that covers it all, in a practical and approachable fashion, authored by .NET guru and Microsoft developer Adam Nathan.<br><br> <br><br>· Covers everything you need to know about Extensible Application Markup Language (XAML) <br><br>· Examines the WPF feature areas in incredible depth: controls, layout, resources, data binding, styling, graphics, animation, and more <br><br>· Features a chapter on 3D graphics by Daniel Lehenbauer, lead developer responsible for WPF 3D <br><br>· Delves into non-mainstream topics: speech, audio/video, documents, bitmap effects, and more <br><br>· Shows how to create popular UI elements, such as features introduced in the 2007 Microsoft Office System: Galleries, ScreenTips, custom control layouts, and more <br><br>· Demonstrates how to create sophisticated UI mechanisms, such as Visual Studio-like collapsible/dockable panes <br><br>· Explains how to develop and deploy all types of applications, including navigation-based applications, applications hosted in a Web browser, and applications with great-looking non-rectangular windows <br><br>· Explains how to create first-class custom controls for WPF <br><br>· Demonstrates how to create hybrid WPF software that leverages Windows Forms, ActiveX, or other non-WPF technologies <br><br>· Explains how to exploit new Windows Vista features in WPF applications<br><br> <br><br><br><br>About the Author<br>Adam Nathan is a senior software development engineer in Microsoft’s Developer Division. He is the author of the acclaimed .NET and COM: The Complete Interoperability Guide (SAMS, 2002), a coauthor of ASP.NET: Tips, Tutorials, and Code (SAMS, 2001), and a contributor to books such as .NET Framework Standard Library Annotated Reference, Vol. 2 (Addison-Wesley, 2005) and Windows Developer Power Tools (O’Reilly, 2006). Adam regularly speaks at development conferences and to groups within Microsoft about a variety of .NET Framework topics. Having started his career on Microsoft’s Common Language Runtime team in 1999, Adam has been at the core of .NET technologies since the very beginning. Adam is also the creator of popular tools and websites for .NET developers, such as PINVOKE.NET, CLR SPY (and its Visual Studio add-in), and XAMLshare.com. You can find him online at www.adamnathan.net. <br><br> <br><br>Daniel Lehenbauer is the lead software design engineer responsible for the 3D features in Windows Presentation Foundation. Prior to WPF, he worked on multiple graphics and UI technologies, including mobile controls for ASP.NET and Windows Forms. Daniel is active in the WPF community and blogs about 3D graphics using WPF at www.viewport3D.com.<br><br>
### 回答1: 这个异常通常是由于XAML文件中的根元素的类型与代码中的类型不匹配引起的。请确保XAML文件中的根元素的类型与对应的代码文件中的类型一致。如果您使用的是自定义控件,请确保命名空间、类名和XAML文件中的名称都正确。您还可以检查XAML文件是否正确地加载到应用程序中。如果上述方法都无效,您可以尝试在代码中手动加载XAML文件,并检查是否存在其他错误。 ### 回答2: System.Windows.Markup.XamlParseExceptionWPF应用程序中常见的异常之一,通常发生在XAML解析过程中。该异常表明在XAML文件中指定的类名称与实际的根实例类型不匹配。 当WPF应用程序加载XAML文件时,系统会尝试根据XAML文件中的类名称创建对应的实例,并将其作为应用程序的根实例。如果XAML文件中指定的类名称与实际的根实例类型不匹配,就会引发XamlParseException异常。 解决这个问题的方法有以下几种: 1. 检查XAML文件中的类名称是否与实际的根实例类型一致。确保类名称的拼写和大小写与实际的类型完全匹配。 2. 检查XAML文件中的命名空间是否正确。确保XAML文件中引用的命名空间与实际的根实例所在的命名空间一致。 3. 检查XAML文件中是否存在其他与根实例相关的错误。例如,如果根实例的构造函数参数有误,也可能导致该异常的发生。 如果以上方法都没有解决问题,可以尝试重新生成或清理解决方案,以确保生成的二进制文件与XAML文件匹配。 总而言之,System.Windows.Markup.XamlParseException异常的原因是XAML文件中指定的类名称与实际的根实例类型不匹配。解决这个问题的方法是检查类名称、命名空间和其他与根实例相关的错误,并确保重新生成或清理解决方案。 ### 回答3: System.Windows.Markup.XamlParseExceptionWPF程序中常见的一种异常,通常在解析XAML文件时出现。 当出现这个异常时,它通常表示XAML文件中指定的类名称与实际根实例类型不匹配。这可能是因为XAML文件中指定的类名称与实际代码中的类名称不一致,或者XAML文件中存在错误的命名空间。 要解决这个问题,我们可以按照以下步骤进行排查和修复: 1. 首先,检查XAML文件中指定的类名称是否与实际代码中的类名称一致。确保在XAML文件中指定的类名称正确无误。 2. 检查XAML文件中的命名空间是否正确。确保XAML文件中的命名空间与实际代码中的命名空间一致。 3. 确保XAML文件中的根元素类型与实际代码中的根元素类型一致。如果XAML文件中的根元素使用了自定义类,那么确保该类的名称和命名空间都正确无误。 4. 检查XAML文件的语法错误。语法错误可能导致解析失败,进而抛出XamlParseException异常。确保XAML文件中的语法正确无误。 5. 如果上述步骤都没有解决问题,可以尝试重新生成项目,以确保XAML文件和实际代码之间的一致性。 总之,System.Windows.Markup.XamlParseException异常通常表示XAML文件中指定的类名称与实际根实例类型不匹配。我们需要仔细检查XAML文件中的类名称、命名空间和语法错误,以确定并解决问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

神也畏惧小卢

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值