This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I would like to add a context menu that only shows up when the user right clicks on the label area of a property. I want to do this to provide a "Reset to Default" option, similar to the behavior in visual studio. I'm currently using the PropertyGrid.ContextMenu property, but this allows the menu to appear anywhere in the grid. I considered doing using a hit test, but I'm unsure of how to traceback the resulting IInputElement back to a particular part of the grid. My last idea is to do a custom label style as outlined here: http://www.mindscape.co.nz/forums/Thread.aspx?PostID=2052 But I'm really hoping someone can suggest an easier way. |
|
|
For hit testing, you should be able to traverse up the visual tree using VisualTreeHelper.GetParent until you get to a TreeListViewItem. (If you have an IInputElement, you'll need to cast it to a DependencyObject before you can pass it to GetParent.) That TLVI represents the row of the grid. Once you have the TLVI, its Header property should be a PropertyGridRow. From this you can get the Node, from which in turn you can get the property name or descriptor or whatever you need to perform the Reset action. |
|