I have an Obseravable Collection
of Items. The collection is displayed in the treeview. I want to enable removing an Item from the collection using context menu. I don't know how can I do that.
For instance, Let's say I have 4 treeviewitems (which means i have 4 Items in the Obseravable Collection
) Now, the user wants to remove the second Item, he right clicks on the second treeviewitem, a context menu is opened and he presses on "Remove.." How can I identify which item to remove from the Collection? (I'm doing it using the Command
)
The context menu looks like this:
<ContextMenu x:Key="RemoveItemMenu">
<MenuItem Header="Remove..." Command="RemoveItem"/>
</ContextMenu>
And the Command function that will be excecuted:
private void RemoveItemExcecute()
{
//Removing the clicked Item out of the collection
}