Inspecting XAML in Windows 8 Store Apps / VS2012

前端 未结 4 1643
终归单人心
终归单人心 2021-02-06 06:15

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 g

4条回答
  •  眼角桃花
    2021-02-06 06:32

    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.

    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"
    

    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.

    Other options include

    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.

提交回复
热议问题