Snoop around your visual tree
Tags: debugging, wpf, opensource, softwaredeveloping
Published: 2019-06-20 10:41:16

---
title: Snoop around your visual tree
published: true
date: '2019-06-20T10:41:16.593Z'
tags: debugging, wpf, open-source, software-developing
canonical_url: https://medium.com/@dvirsegal/snoop-around-your-visual-tree-81c6b4e311b3
---

![Visual Tree — Photo by [Johann Siemens](https://unsplash.com/@johannsiemens?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)](https://cdn-images-1.medium.com/max/800/0*ZfXTwwHsgllR6nzJ)

<span>
<em>Originally published at <a href="https://medium.com/@dvirsegal/snoop-around-your-visual-tree-81c6b4e311b3" style="color:#1395b8">Medium</a> on <time datetime="2019-06-20T10:41:16.593Z" title="Thursday, June 20, 2019, 10:41:16 AM">Jun 20, 2019 </time>
</em>
</span>

Binding issues? Struggle with that hard to solve UI bug? Trying to understand how to fit the entire string into TextBox’s dimensions? These situations and many others are common for us, .NET and WPF developers.

Most of the times, issues, as mentioned above, are solved by using a debugger.

Imagine it; you want to change the size of a specific graphic element. Well, you open the relevant project (using [Everything](https://medium.com/@dvirsegal/its-all-about-everything-95043d1b0aa) tool 😉) in your favorite IDE, make some changes, compile, deploy, and rerun the application. Then you attach a debugger. Investigate and rerun the whole process again until you solve the issue.

Well, It takes time. A LOT of it.

[Snoop](https://github.com/snoopwpf/snoopwpf) was developed by [Pete Blois](https://github.com/peteblois) to ease the pain of debugging your WPF application. This open source WPF spying utility, now maintained by [Cory Plotts](http://www.cplotts.com/), allows on the fly visual tree changes, troubleshooting binding failures, and more…

![[xkcd: Compiling](https://imgs.xkcd.com/comics/compiling.png)](https://cdn-images-1.medium.com/max/800/1*J-1MC3QGbIuwq4tb-yr-iA.png)

#### Spying on your app

Download and install Snoop from its Github repository:

[**snoopwpf/snoopwpf**](https://github.com/snoopwpf/snoopwpf/releases)

Launch Snoop and drag the snooping cross-hair to your WPF application.

![Snoop window, the snooping cross-hair is marked with a red rectangle](https://cdn-images-1.medium.com/max/800/1*83wftet6QNifOIUPTey1Eg.png)
Snoop window, the snooping cross-hair is marked with a red rectangle

A new window is opened. On the left, the application’s visual tree is displayed while on the right, the property editor is visible for each element in the list. Below a GIF that demonstrates the primary usage of Snoop. It can be seen that one of TextBlock’s Text property content is being edited on the fly.

![Snooping example](https://cdn-images-1.medium.com/max/800/1*nM5_Hji8Gx5dztEjUdzoHQ.gif)

#### Features

Ctrl+Shift keyboard buttons and hovering over the desired element is a productivity boost. It causes Snoop to jump immediately to the hovered element’s properties, which saves you the effort of going down the visual tree to find the desired control, as seen below:

![Ctrl+Shift trick](https://cdn-images-1.medium.com/max/800/1*tXSaNQgXt0Sf8i77KOea9A.gif)

Another trick is to search the property you would like to change in the filter box. Furthermore, a useful feature is the “Show only visuals with binding errors” option found in search-bar drop-down located above the visual tree view.

![Show only visuals with binding errors](https://cdn-images-1.medium.com/max/800/1*t_1gdBtJFlQmYl_6dTwv7w.png)

It shows components with binding issues. In such way, it saves time to identify any binding failure using your IDE.

![[Moar Features](https://memegenerator.net/instance/65792011/roar-cat-moar-features)](https://cdn-images-1.medium.com/max/800/0*2t29S2ejFM1RrcLB.jpg)

There are more features in Snoop which are less used (IMHO). For example, the power-shell which is a console where you can write methods and interact with the UI through commands. Events tab that lists all the fired events per your limited choice and triggers tab for debugging any changes happened for control or style through a trigger, whether it is a property trigger, DataTrigger or EventTrigger.

#### Summary

Although its UI is not much user-friendly, I’ve found it to be handy for finding missing bindings and tweaking layout parameters. As well, overcoming the effort of debugging an unfamiliar complex user interface since Snoop projects the visual tree and allows to navigate in it quickly.

Furthermore, Similar WPF spying utilities exist (such as [Mole](https://www.codeproject.com/articles/21441/mole-for-wpf-multifunction-visual-studio-visualize) and [WPF inspector](http://www.wpftutorial.net/Inspector.html)), but Snoop has an active open source development, and it saves you the headache of using your IDE for debugging your application. I cannot imagine developing WPF interfaces without it.

BTW, [HawkEye](https://github.com/odalet/Hawkeye2) (Maintained by [Olivier Dalet](https://github.com/odalet)) is another opensource tool with similar capabilities that allows snooping your WinForms application.