我在 WPF 中有一个图表,当我右键单击图表时,它会转到函数 Chart_mouseRightButtonDown,如下所述。我想添加一个上下文菜单。我已经在上下文菜单中添加了两个选项。但是现在我想要一些操作当用户单击软管选项时。如何向其中添加处理程序?
private void Chart_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
var originalSource = e.OriginalSource as DependencyObject;
if (originalSource is Ellipse)
{
ContextMenu contextMenu = new ContextMenu();
contextMenu.Items.Add("Lookup Details in Grid");
contextMenu.Items.Add("Lookup Defect Info");
runTrendChart.ContextMenu = contextMenu;
}
else
runTrendChart.ContextMenu = null;
}