Click here to Skip to main content
14,335,049 members

Mole II Black Ops - Multifunction Visual Studio Visualizer For WPF - View Public, Private and Protected Data

, ,
Rate this:
4.77 (15 votes)
Please Sign up or sign in to vote.
4.77 (15 votes)
17 Dec 2007CPOL
A high octane multifunction visualizer that allows detailed inspection of the visual tree and logical trees. New feature of Mole II Black Ops allows viewing and drilling into non-public members of any element or sub-element in the visual or logical trees.

Mole 2010 is Now Available


If you are using Visual Studio 2010 and would like to use the Mole debugging tool, please visit to get your copy today. Mole 2010 makes debugging easier.

Mole for Visual Studio Released

All versions of Mole have been replaced by Mole For Visual Studio.

Please refer to this article Mole For Visual Studio.

This article is here for informational purposes. The downloads have been removed. Please download and use Mole For Visual Studio. Thank you!


This is the third article in the Mole WPF Visual Studio Visualizer series. This article covers a new and exciting feature - Black Ops. Black Ops enables Mole to return non-public members of objects that are selected in the visual or logical trees. Additionally, non-public members can also be returned during a drilling operation.

Previous Mole Articles

This article focuses on the new features added to Mole II. If you have not read the below articles, please read them to fully understand Visual Studio Visualizers and Mole.

Read Mole v1 Code Project Article.

Read Mole II v2 Code Project Article.

Mole's Home Page and Manual

Read Mole's Manual and visit Mole's Home Page.

Mole's Email

Please send your comments and feedback to

Team Mole

Mole was authored by Karl Shifflett, Josh Smith and Andrew Smith.

Karl wrote this article which is why "I" appears in the article and I make references to myself.


I have been amazed at the response that Mole & Mole II have received. One such response came from a super developer and great guy from the Raleigh, NC area, Rob Zelt. He wrote this blog post on Mole II. In this posting, he wondered if Mole would work with Silverlight applications. I did the research and as of Silverlight 1.1, visualizers are not supported. I do not know if they will be in Silverlight 2.0 scheduled to be released Q1 2008.

If visualizers will not be supported in Silverlight 2.0, I have come up with two alternate methods to provide Silverlight developers Mole functionality and will write the program shortly after the release of Silverlight 2.0. I would welcome suggestions from Silverlight developers for this product. Please leave comments at the bottom of this article or on my blog.

During my investigation of Silverlight and Mole, many new ideas started to surface. One of them was viewing and drilling into private and protected members. Currently Mole views public objects and properties. So we can thank Rob Zelt for asking me this question which lead to this code being authored and Mole getting Black Ops capabilities.

Where did this Black Ops business come from? Well, I was going to call it, "Mole! Show me your privates!" (private members right). Actually Mole took a left turn and ended up on the set of 24 and hung around Jack Bauer too long. Just keeping it fun!

Black Ops is used in this article but in the program UI we have chosen to follow .NET nomenclature and call the private and protected members fields, since that is what is being displayed. Again, just keeping it fun. (Truth be told, Josh talked me out of it.) As you know, you can easily change anything about Mole with very little effort, colors, labels, displayed data, etc.

Mole Black Ops

Mole Black Ops

First off, two columns have been renamed. Property Name has been renamed to Name and Property Type has been renamed to Type. The reason for this is that the Black Ops items can now be properties or fields.

In the above image, a TabControl has been selected in the Visual Tree TreeView Control. The breadcrumb points this out. We can see the Favorites this user has set up and the values that are displayed. Below the Favorites section is the new Fields (Black Ops) section.

Fields (Black Ops) Section

  • Region is pinned (frozen like the Favorites section).
  • Region supports collapse/expand.
  • Field items may be assigned to the Favorites section. If assigned to Favorites that field will be displayed with the Favorites.
  • Field items have their Category Name set to ({field attribute} Field). {field attribute} is from the FieldInfo.Attributes that you can read about in this MSDN FieldInfo.Attributes article.
  • Field items are all non-public fields and non-public properties.
  • Field items support drilling like their public members do.
  • Google search has been disabled for all Field items since the search would return strange results.

Below the Search TextBox there is a new Show Fields CheckBox which allows the Fields section to not be displayed if desired. This setting is persisted between Mole sessions.

Black Ops Collapsed

Black Ops Collapsed

The Fields section has been collapsed.

Black Ops Data

Black Ops Data

Some would ask, why show Private or Protected members? Allow me to list two reasons.

In the above image, I have selected a String from the logical tree. Notice the members of the String Class. Mole Black Ops has revealed some internal information that I never knew about before I started drilling around using Black Ops. I spent about an hour just drilling around and checking out WPF's classes using this feature.

The real reason I wanted this feature was to be able to view Private and Protected members that I have defined in my own classes. Now when I'm using Mole, I can view and drill into the module level Private and Protected members of classes I have written. This provides a more in-depth view of my class data.

Private and Protected Data

For Each obj As System.Reflection.FieldInfo In _
  target.GetType.GetFields(BindingFlags.NonPublic Or _

    Dim bolIsDepencencyProperty As Boolean = False

    'note the default value is set to null

    Dim strValue As String = STRING_NULL
    Dim strValueSource As String = String.Empty
    Dim bolIsDrillable As Boolean = False


        Dim objValue As Object = obj.GetValue(target)

        If objValue IsNot Nothing Then
            strValue = objValue.ToString
            bolIsDrillable = _
              IsDrillableTest(obj.ReflectedType, objValue)
        End If

    Catch ex As Exception
        'just ignoring the exception

    End Try

    objList.Add(New TreeElementProperty(bolIsDepencencyProperty, _
      bolIsDrillable, _
      String.Format(STRING_BLACK_OPS_INDICATOR_FORMAT, obj.Attributes.ToString), _
      obj.Name, obj.FieldType.Name, strValue, strValueSource))

Viewing Private and Protected members of an object is really quite simple. It requires the use of .NET reflection. The Type.GetFields method returns a collection of FieldInfo objects. This method has an overload that allows the developer to specify what fields in the target object to return by passing the BindingFlags parameter. In the above code, I'm passing BindingFlags.NonPublic Or BindingFlags.Instance.

Because of the way Mole is designed, adding this feature was very simple. I inserted the above code at the end of the MoleVisualizerObjectSource.GetTreeElementProperties function.

The GetTreeElementProperties function exposes some of the internal workings of Mole. It is here that data displayed in the properties grid is checked if it is drillable or not.

You can also see that Mole is string based. Look at what the UI is passed in the above objList.Add call. A bunch of strings!

Since the UI for Mole and the data source for Mole are in two separate processes, the UI does not have any references to the data it displays. It is this utterly simplistic design that allows Mole to be easily extended. It is the responsibility of the Mole's data source to maintain references to objects that Mole is viewing so that those objects can be drilled into when the user desires.


Unless there is a bug, this might be the last installment of Mole until the Silverlight version in Q1 2008. Karl needs to get back to work on a multi-player WPF game he has been working on. The game should be released in stores Q2 2008.

Hope this article can help someone learn a little more about Visual Studio Visualizers For WPF.


  • 11 December 2007: Initial release


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Authors

Josh Smith
Software Developer (Senior) Black Pixel
United States United States
Josh creates software, for iOS and Windows.

He works at Black Pixel as a Senior Developer.

Read his iOS Programming for .NET Developers[^] book to learn how to write iPhone and iPad apps by leveraging your existing .NET skills.

Use his Master WPF[^] app on your iPhone to sharpen your WPF skills on the go.

Check out his Advanced MVVM[^] book.

Visit his WPF blog[^] or stop by his iOS blog[^].

See his website Josh Smith Digital[^].

Karl Shifflett
United States United States

I’m a passionate Software Architect and Developer.

A long-time WPF-Prism fanatic who enjoys writing line of business applications, developer tools, and Visual Studio Extensions.

My front end passions are WPF, Xamarin.Forms, Electron, ES2015 (ES6), Node.js, WordPress, and Angular.

For the back end I use what is appropriate for the project: SQL Server and ASP.NET WebAPI, MongoDB, Express, Azure, AWS, Firebase, etc.

I am very pragmatic software engineer and strive to write simple, maintainable, and testable code. Simple code allows for solving complex problems in a maintainable way.

My Blog

My Github Repros

Just a grain of sand on the worlds beaches.

Andrew Smith
Architect Infragistics, Inc.
United States United States
Andrew currently works as an architect for Infragistics working with windows forms and WPF. You can check out his blog here.

Comments and Discussions

GeneralSuggestion - Resource Visualizer Pin
KevinKerr13-Dec-07 7:54
memberKevinKerr13-Dec-07 7:54 
GeneralRe: Suggestion - Resource Visualizer Pin
Karl Shifflett13-Dec-07 16:48
memberKarl Shifflett13-Dec-07 16:48 
GeneralRe: Suggestion - Resource Visualizer Pin
Josh Smith14-Dec-07 1:52
memberJosh Smith14-Dec-07 1:52 
GeneralRe: Suggestion - Resource Visualizer Pin
KevinKerr14-Dec-07 3:31
memberKevinKerr14-Dec-07 3:31 
GeneralRe: Suggestion - Resource Visualizer Pin
Josh Smith14-Dec-07 3:36
memberJosh Smith14-Dec-07 3:36 
General110, 767 KB Pin
Rama Krishna Vavilala11-Dec-07 6:58
memberRama Krishna Vavilala11-Dec-07 6:58 
GeneralRe: 110, 767 KB Pin
Karl Shifflett11-Dec-07 7:56
memberKarl Shifflett11-Dec-07 7:56 
GeneralRe: 110, 767 KB Pin
Karl Shifflett11-Dec-07 8:00
memberKarl Shifflett11-Dec-07 8:00 
GeneralLove it, but... Pin
Kent Boogaart11-Dec-07 5:43
memberKent Boogaart11-Dec-07 5:43 
GeneralRe: Love it, but... Pin
Josh Smith11-Dec-07 5:50
memberJosh Smith11-Dec-07 5:50 
GeneralRe: Love it, but... Pin
Karl Shifflett11-Dec-07 6:49
memberKarl Shifflett11-Dec-07 6:49 
GeneralRe: Love it, but... [modified] Pin
Karl Shifflett11-Dec-07 11:01
memberKarl Shifflett11-Dec-07 11:01 
GeneralRe: Love it, but... Pin
Kent Boogaart11-Dec-07 22:48
memberKent Boogaart11-Dec-07 22:48 
GeneralLovin' it! Pin
Josh Smith11-Dec-07 3:57
memberJosh Smith11-Dec-07 3:57 
GeneralRe: Lovin' it! Pin
Karl Shifflett11-Dec-07 4:37
memberKarl Shifflett11-Dec-07 4:37 
GeneralRe: Lovin' it! Pin
Josh Smith11-Dec-07 4:40
memberJosh Smith11-Dec-07 4:40 
GeneralRe: Lovin' it! [modified] Pin
Karl Shifflett11-Dec-07 4:54
memberKarl Shifflett11-Dec-07 4:54 
JokeRe: Lovin' it! Pin
Josh Smith11-Dec-07 4:55
memberJosh Smith11-Dec-07 4:55 
GeneralRe: Lovin' it! Pin
Sacha Barber12-Dec-07 1:59
mvaSacha Barber12-Dec-07 1:59 
GeneralRe: Lovin' it! Pin
Karl Shifflett12-Dec-07 2:02
memberKarl Shifflett12-Dec-07 2:02 
GeneralRe: Lovin' it! Pin
Sacha Barber12-Dec-07 2:54
mvaSacha Barber12-Dec-07 2:54 
GeneralRe: Lovin' it! Pin
Karl Shifflett12-Dec-07 2:56
memberKarl Shifflett12-Dec-07 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 11 Dec 2007


32 bookmarked