I have written before about being part of the Snoop team – contributing to the open source code base for the WPF spying utility. In the past couple months, we gained some good momentum on some cool new features, and now we are proud to announce the availability of the next release: Snoop 2.8.0. Special shout out to Cory Plotts for all his work in getting this release out.
Download the latest installer here.
Here is a rundown of some of the new features in the new version.
Capture Changes to Properties
My coworkers and I often times end up using Snoop as a kind of “run-time designer”. Blend can only go so far to show us the run-time look of a given view or control, so we Snoop into our running application and make changes to various properties (font sizes, margins, alignments, etc). We make these changes interactively, deciding what looks good, and then have to adjust the XAML code accordingly. If you’ve made changes to more than a couple properties, it’s easy to forget what all the changes were. This feature will save you.
Whenever you close the Snoop window or the Snooped application, any changes you’ve made to properties during that Snoop session are copied to the clipboard. You can then paste them into a text editor somewhere to get the concise list of changes. You don’t have to wait until you stop Snooping to get the list of changes. You can also hit CTRL+SHIFT+C at any time while Snooping to copy the changed property info to the clipboard. Here’s an example of a set of changes:
Snoop dump as of 2012-10-08 16:34:23 --- OBJECTS WITH EDITED PROPERTIES --- Object:  Rect1 (Rectangle) Property: Fill, New Value: #FF00208B Property: Height, New Value: 40 Object:  Rect4 (Rectangle) Property: Canvas.Top, New Value: 45 Object:  txtInput (TextBox) 10 Property: Text, New Value: hello world
The output is organized in a hierarchy, listing each object that contains at least one property that was changed, and then grouping all the changed properties on that object together. The identifier for the object matches how it’s displayed in the Snoop visual tree UI.
Show Binding Paths
WPF is all about Bindings. You have a ton of them in any “real” WPF app. Often, even when the binding is working, I want to see the Path the binding is using, maybe as a way to quickly find the VM property backing a particular UI element. I decided that a bound property in Snoop should show you the Binding.Path right away, without making you delve into the Binding to see that important info. Here are some screenshots of various bindings in my sample app:
Basic Binding – shows full property path in brackets next to the value
ElementName Binding – shows both the Path and ElementName
MultiBinding – shows each Path and optional ElementName
PriorityBinding – shows each Path in priority order
Show Resource Keys
Since we’ve moved the Snoop source code to GitHub, we’ve been receiving some pull requests with various feature implementations. One of them, from Dawn Wright, is simple, yet powerful. Now when Snoop displays a Brush or Style that is a keyed resource, it will show you the x:Key property of the resource. This is super valuable when Snooping through an app that you didn’t write, allowing you to find the resources a given object uses. Here’s are a couple examples:
Inline Brush – not referencing a keyed resource (notice any Type is now in [brackets] )
Brush that References a Keyed Resource
Style that References a Keyed Resource
I’m not a huge PowerShell user, but I can already tell this contribution from Bailey Ling is a killer new feature. There is a new PowerShell tab in the Snoop window that lets you party on your objects, using PowerShell commands. The most basic commands that I know are to set a variable that points to the DataContext of one of your elements, then start making calls to properties and methods in that object graph.
$vm = $selected.Target.DataContext $vm.Name = “foo”
The possibilities are endless…
Other Minor Enhancements
ESC key now clears any current search filter.
If Snoop throws an exception from within itself, we catch it and don’t blow up your app.