I have a list view with a context menu. I am looking to dynamically add an item which has a click event. As you can see below, doing it statically is pretty straight forward in the XAML. However, when I try to do this in C# it will not compile. I've checked several existing StackOverflow questions, but they seem to be using different controls or are for WinForms instead.
<ListView x:Name="listView" Margin="10,7,10,8">
<ListView.ContextMenu>
<ContextMenu>
<MenuItem x:Name="Test" Header="Test" Click="Test"/>
</ContextMenu>
</ListView.ContextMenu>
<ListView.View>
ModuleName is the name and DisplayModule() is the click handler event I want.
