My application is implemented by a GridView
inside a TreeList
.
Much to my despair, I discovered that the GridView is very primitive, compared to the widely used DataGrid
. I am considering these two options:
(1) Somehow, I replace the GridView with a DataGrid (which supports Context Menu).
(2) Somehow, I add the Context Menu capability to the existent GridView.
Which of the 2 approaches (or another?) would you recommend?
Source code is much appreciated.
TIA.
Based on the linked code, here is the solution:
1 - Add the
ContextMenu
as a Resource:It is recommended that you set
x:Shared="False"
to prevent Binding issues related to reusing the resource instance.2 - Define an
ItemContainerStyle
for your TreeList that sets the ContextMenu for theTreeListItem
s:Notice that I'm using DataBinding in the
ContextMenu
, which means you have a proper, workingDataContext
in it. You should be able to useCommands
and other stuff in it.