简体   繁体   中英

How to “Snoop” a ContextMenu?

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 ?

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
  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM