在 Windows 8 Store Apps/VS2012 中检查 XAML [英] Inspecting XAML in Windows 8 Store Apps / VS2012

查看:22
本文介绍了在 Windows 8 Store Apps/VS2012 中检查 XAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来检查在 Windows 8 商店应用中运行的 XAML.本质上,我想要 firebug/chrome 检查器样式功能,我可以在其中查看运行时生成的 XAML 源,以调试简单的布局和样式问题.

I'm looking for a way to inspect running XAML in a Windows 8 store app. Essentially, I want firebug / chrome inspector style functionality where I can look at the XAML source generated at runtime, to debug simple layout and style issues.

我尝试过 Snoop、Pistachio 和 WPF Inspector,但都不适用于 Windows 应用商店应用.我能找到的唯一一个似乎适用于 Store 应用程序的是 XAML Spy,它是 90 欧元.我无法证明这笔费用是合理的.

I've tried Snoop, Pistachio and WPF Inspector but none work for Windows Store apps. The only one I can find which seems to work for Store apps is XAML Spy, which is €90. I can't justify that cost.

有没有其他方法可以检查正在运行的 XAML?

Is there any other way to inspect running XAML?

推荐答案

如果您需要免费工具,可以使用 WinRT XAML 工具包中的 VisualTreeDebugger 类.它不像 XAML Spy 那样做,但一分钱一分货.我想为它添加更多功能,比如调试内容的实际可视化,但所需的工作不能证明时间投入是合理的 + 我不想踏上 Koen Zwikstra 的地盘.我相信他在这个工具上做得很好.无论如何 - VisualTreeDebugger 对我来说已经足够了,所以也许对你来说也足够了.

The VisualTreeDebugger class from WinRT XAML Toolkit is what you could use if you want a free tool. It doesn't do as much as XAML Spy, but you get what you pay for. I thought of adding more features to it like actual visualization of what you debug, but the work required would not justify the time investment + I didn't want to step on Koen Zwikstra's turf. I am sure he is doing a great job on that tool. Anyways - VisualTreeDebugger is enough for me, so maybe it would also be enough for you.

您可以使用它的方式是将类添加到您的代码中,在您的 XAML 中添加一个引用,例如

The way you can use it is add the class to your code, add a reference in your XAML like

xmlns:debug="WinRTXamlToolkit.Debugging"

然后在您要开始调试的控件上放置一个钩子,例如

then put a hook on a control where you would like to start debugging, like

debug:VisualTreeDebugger.BreakOnLoaded="True"

这将在调试器输出窗口 (Ctrl+W,O) 中将核心可视化树详细信息转储为文本,并中断转储树的代码,您可以在其中调查路径"变量,其中包含所有从调试控件到根的可视化树元素,因此如果您需要的内容尚未转储到输出窗口中,您可以查看它们的值.

which will dump the core visual tree details as text in your debugger output window (Ctrl+W,O) and break in the code that dumped your tree where you can investigate the "path" variable, which contains the list of all visual tree elements from the debugged control to the root, so you can watch their values if what you need wasn't already dumped in the output window.

其他选项包括

debug:VisualTreeDebugger.BreakOnTap="True"
debug:VisualTreeDebugger.BreakOnLayoutUpdated="True"
debug:VisualTreeDebugger.BreakOnLoaded="True"
debug:VisualTreeDebugger.TraceOnTap="True"
debug:VisualTreeDebugger.TraceOnLayoutUpdated="True"
debug:VisualTreeDebugger.TraceOnLoaded="True"

由于它是源代码并且实际上是一个简单的类 - 您可以轻松地向代码中添加其他内容以执行您需要的任何自定义调试.

Since it is source code and really a single simple class - you can easily add additional things to the code to do any custom debugging you need.

这篇关于在 Windows 8 Store Apps/VS2012 中检查 XAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆