This project is read-only.

How to use VisualTreeDebugger

Mar 29, 2013 at 12:14 AM
I want to use VisualTreeDebugger to inspect the XAML at run time. here is what I did:
  1. Installed "Debugging Tools" using "Install-Package WinRTXamlToolkit.Debugging"
  2. Added a reference in my XAML file: "xmlns:debug="WinRTXamlToolkit.Debugging""
  3. Put a hook on a control (a button): "debug:VisualTreeDebugger.BreakOnLoaded="True"".
  4. You can see the XAML at the end
  5. It complains: "The name 'VisualTreeDebugger' does not exist in the namespace "WinRTXamlToolkit.Debugging".
What am I missing?

Thank you,

Nicu

<Page
x:Class="App3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:debug="WinRTXamlToolkit.Debugging"
mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Button Name="Button1" Content="Button 1" Click="Button1_Click" Grid.Row="0" Grid.Column="0" debug:VisualTreeDebugger.BreakOnLoaded="True" />
    <TextBlock Name="TextBlock1" Grid.Row="0" Grid.Column="1" >I am a text block.</TextBlock>
</Grid>
</Page>
Mar 29, 2013 at 12:17 AM
I think this is a bug in the Visual Studio designer tool and even though the error shows up in the errors panel - it should still build and run. Also - I recommend using XAML Spy if this doesn't work out. It's a great tool and has a free trial IIRC.
Mar 29, 2013 at 12:23 AM
Actually it does not build. There are three errors in Error List
Error 1 The name "VisualTreeDebugger" does not exist in the namespace "WinRTXamlToolkit.Debugging". c:...\App3\MainPage.xaml 19 102 App3
Error 2 The attachable property 'BreakOnLoaded' was not found in type 'VisualTreeDebugger'. c:...\App3\MainPage.xaml 19 102 App3
Error 3 Unknown attachable member 'VisualTreeDebugger.BreakOnLoaded' on element 'Button' c:...\App3\MainPage.xaml 19 102 App3
Mar 29, 2013 at 12:27 AM
That's strange. I'll need to check it when I have a moment. Perhaps it was built in Release solution configuration. It is configured to only show up in Debug. For now you can simply grab the class from the source code and plop it in your code instead of using the NuGet package.

Here's the link:

http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/9c814f6c67c540adbd6952821a351d9ffa4d1d99#WinRTXamlToolkit.Debugging/VisualTreeDebugger.cs
Mar 29, 2013 at 12:32 AM
I've built Debug
Apr 2, 2013 at 5:09 AM
Hmmm, I am definitely missing something. I’ve added that class into my project with the same result. I’ve added all the Toolkit projects to my solution with the same result.
Do I need to set anything else on my project?

Thank you,

Nicu
Apr 7, 2013 at 11:21 PM
Hi,

I am stuck with this issue I am having? Don't know why it doesn't work for me. Can anyone help please?

Thank you,

Nicu
Apr 7, 2013 at 11:41 PM
Can you share a sample project where it doesn't work?
Apr 8, 2013 at 12:13 AM
I prepared a project but I cannot figure out how to attach a .zip file to the thread.
Apr 11, 2013 at 2:24 AM
Could you please help me sharing the sample project? How do I attach it to the thread? Or there is a different way to share it?