ChartView Context Menu

3 posts, 1 answers
  1. Josh
    Josh avatar
    2 posts
    Member since:
    Nov 2011

    Posted 20 Apr 2012 Link to this post

    I am trying to get a context menu to display when I right-click on a datapoint in a BarSeries.

    I am able to add a context menu to the entire Cartesian Chart, but I want my context menu to be specific to the selected DataPoint.DataItem.

    <telerik:BarSeries ItemsSource="{Binding DataView, ElementName=GroupsDataSource}" CombineMode="Cluster" ClipToPlotArea="False" AllowSelect="True" ShowLabels="True" MinWidth="30" Margin="5,0">
         <telerik:RadContextMenu ItemClick="GroupContextMenu_ItemClicked" EventName="MouseRightButtonUp">
              <telerik:RadMenuItem x:Name="rmiCodeBar" Header="View Code Breakout (Bar)">
              <telerik:RadMenuItem x:Name="rmiCodePie" Header="View Code Breakout (Pie)">

    I am also not sure how to get to the DataItem of the clicked point, as the below wont let me use DataPoint as the type.

    private void GroupContextMenu_ItemClicked(object sender, RadRoutedEventArgs e)
           RadMenuItem item = e.OriginalSource as RadMenuItem;
           var actingOn = ((RadContextMenu)sender).GetClickedElement<DataPoint>();
           switch (item.Name)
               // Create drill down charts based on what is selected
  2. Answer
    Giuseppe avatar
    2363 posts

    Posted 24 Apr 2012 Link to this post

    Hello Josh,

    We have attached a sample application that demonstrates how to achieve the desired functionality.

    Note that the current version of RadCartesianChart has some limitations with regards to the support of context menu scenario (due to the current internal container structure of the control mouse input normally is not propagated to the series item visuals thus context menu cannot be properly notified to visualize itself). We have applied a workaround in the form of RadCartesianChart implicit style with custom template that addresses this problem but note that using this implicit style is only suggested if you want to use context-sensitive context menu items as it effectively disables the built-in interactive behaviors of the chart control like pan/zoom, trackball, selection, and tooltips.

    Our developers are aware of the described limitation and will do their best to address it for the Q2 2012 release of the control.

    Hope this helps.

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Josh
    Josh avatar
    2 posts
    Member since:
    Nov 2011

    Posted 30 Apr 2012 Link to this post

    Thanks for the reply. For this particular use, I value the Selection and Tooltip behaviors more than the Context menu, so I will make do with a static menu dynamically driven by the chart's selected data point until the control is updated.
Back to Top