我有下面的图表,我想添加一个上下文mennu并执行各种操作
<charting:Chart Grid.Row="2" Margin="12,0,162,0" Visibility="{Binding Path=ShowRunTrendChart, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter}}" Name="runTrendChart" Title="{Binding RunTrendChartTitle}" MouseLeftButtonDown="Chart_MouseLeftButtonDown">
<charting:Chart.Axes>
<charting:CategoryAxis Orientation="X">
<charting:CategoryAxis.AxisLabelStyle>
<Style TargetType="charting:AxisLabel">
<EventSetter Event="MouseRightButtonDown" Handler="CellClick" />
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</charting:CategoryAxis.AxisLabelStyle>
</charting:CategoryAxis>
<charting:LinearAxis Orientation="Y" ShowGridLines="True"/>
</charting:Chart.Axes>
</charting:Chart>
代码:
ContextMenu topMenuItem = new ContextMenu();
//topMenuItem.MenuItems.Add("Hello", new EventHandler(pop_Clicked));
topMenuItem.DataContext = "rr";
runTrendChart.ContextMenu=topMenuItem;
我正在做上面的代码来做到这一点。但它不起作用。它的意思是“rr” 当我右键点击图表时没有显示。没有文字的小白框出现。有人可以告诉我在图表上添加上下文菜单的正确方法。