在Visual Studio 2012中调试XAML数据绑定(Debugging XAML databinding in Visual Studio 2012)

编程入门 行业动态 更新时间:2024-10-25 06:22:50
在Visual Studio 2012中调试XAML数据绑定(Debugging XAML databinding in Visual Studio 2012)

在Silverlight 5测试版中, 我可以直接在XAML中调试数据绑定 。 Visual Studio 2012(RC)中的此功能在哪里? 我可以用WPF,WinRT和/或Silverlight做到这一点吗? 如果是这样如何? 当我在绑定表达式应用程序上设置一个断点时,我得到这样一条消息,即不会触发断点,因为没有源代码与此行关联。

更新:

它适用于Silverlight 5应用程序的Visual Studio 2012(RC),但不适用于WPF应用程序。 请不要告诉我,WPF不存在此功能!

In the Silverlight 5 beta I could debug databinding directly in XAML. Where is this feature in Visual Studio 2012 (RC)? Can I do this with WPF, WinRT and/or Silverlight? If so how? When I set a breakpoint on a binding expression application, I get the message that the breakpoint will not be hit because no source code is associated with this line.

Update:

It works in Visual Studio 2012 (RC) for Silverlight 5 applications but not for WPF applications. Please don't tell me, that this feature does not exist for WPF!

最满意答案

很抱歉告诉你,但这个特性存在于WPF XAML中,也不存在于WinRT XAML中。 我找不到WPF的官方源代码,但这里是WinRT的官方源代码( http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/fae53937-cb47-45da-b740他非常强烈地暗示,这是纯粹由Silverlight团队领导的努力,并且可能在未来的WPF和WinRT版本中预期。

到目前为止,我见过的最好的调试技术如下:

1)WinRT和WPF:输出窗口使用启用适当选项的输出窗口,确保工具 - >选项 - >调试 - >输出窗口 - >数据绑定=“警告”或其他有用的...

在这里输入图像描述

2)WinRT和WPF:使用转换器使用转换器并在转换器内设置断点。 或者,您可以构建/使用类似于WinRT XAML Toolkit的功能: http : //winrtxamltoolkit.codeplex.com/.../WinRTXamlToolkit.Debugging/Converters/BindingDebugConverter.cs

3)WinRT:使用DebugSettings.BindingFailed

App.Current.DebugSettings.IsBindingTracingEnabled = true; App.Current.DebugSettings.BindingFailed += (s, e) => { // debug the failed binding here };

请参阅: http : //msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.debugsettings.bindingfailed以获取更多信息

4)WPF:使用PresentationTraceSources.TraceLevel附加属性为您提供详细的绑定输出,请参阅: http : //msdn.microsoft.com/en-us/library/system.diagnostics.presentationtracesources.tracelevel.aspx以获取更多信息。

我意识到这是一个较老的问题,但我无法找到XAML的所有信息来源,从搜索引擎中找到这个答案,并注意到它仍然缺乏答案。 技术上来说,XAML的3个版本都以相同的名字命名,这并没有帮助。 所以这里是我在调试绑定时发现的所有东西的转储。 享受,希望它可以帮助别人...... -ck

Sorry to tell you but this feature DOES NOT exist in WPF XAML nor does it exist in WinRT XAML. I can't find an official source for WPF, but here is a pretty official one for WinRT (http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/fae53937-cb47-45da-b740-49f75f8d36e9/) he insinuates pretty strongly that this was an effort spearheaded purely by the Silverlight team and can possibly be expected in future versions of WPF and WinRT.

So far the best debugging techniques I've seen are as follows:

1) WinRT & WPF: Output Window Using the output window with the proper options enabled, make sure Tools->Options->Debugging->Output Window->Data Binding = "Warning" or something else useful...

enter image description here

2) WinRT & WPF: Use a converter Using a converter and just setting a break point inside the converter. Or you can build/use something similar to how WinRT XAML Toolkit does: http://winrtxamltoolkit.codeplex.com/.../WinRTXamlToolkit.Debugging/Converters/BindingDebugConverter.cs

3) WinRT: Use DebugSettings.BindingFailed

App.Current.DebugSettings.IsBindingTracingEnabled = true; App.Current.DebugSettings.BindingFailed += (s, e) => { // debug the failed binding here };

see: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.debugsettings.bindingfailed for more information

4) WPF: Use PresentationTraceSources.TraceLevel Attached Property Gives you a verbose output of the binding, see: http://msdn.microsoft.com/en-us/library/system.diagnostics.presentationtracesources.tracelevel.aspx for more information.

I realize this is an older question, but I couldn't find a good source of information for everything XAML, found this answer off a search engine and noticed it was still lacking an answer. It doesn't help that there are technically 3 versions of XAML going by the same moniker. So here's the dump of everything I found while investigating debugging bindings. Enjoy, hope it helps someone... -ck

更多推荐

本文发布于:2023-08-06 14:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1450213.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   数据   Studio   Visual   databinding

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!