How to "Snoop" a ContextMenu?

2.1k views Asked by At

I have a ContextMenu that uses a CompositeCollection for its ItemsSource. One of the items (the one that is in a bound collection, as opposed to hard-coded) is displayed differently from the rest.

I didn't see anything obvious in the XAML as to why this is, so I thought I would use Snoop to look at the actual rendered style (and find the difference). However, whenever I activate the Snoop window to look for the Context Menu, it closes the menu!

Is there a way to use Snoop (or a similar tool) to inspect a ContextMenu?

2

There are 2 answers

0
Vimal CK On BEST ANSWER

Whenever user performs any action outside of an opened ContextMenu will get closed. This is default behaviour of the ContextMenu, But still Snoop provides all the informations about the ContextMenu and it's MenuItems in the VisualTreeView of the Snoop window on Left side. If you want to snoop a specift ContextMenuItem

  • Attach your application with the Snoop
  • Press Shift+Ctrl and mouse over to the ContextMenuItem you want to snoop which shows a Red border. Also the same control will be selected in the Treeview of the Snoop window
1
AudioBubble On
  • Select your WPF application in Snoop
  • Open the context menu
  • Press Shift+Ctrl and move the mouse pointer to one of the context menu items.