I am developing an application where I need a ContextMenu to appear over a RadChart pie chart. I need to be able to access the DataPoint associated with where the ContextMenu is opened (if any). What is the best approach for this?
Thanks,
Tim
Thanks,
Tim
4 Answers, 1 is accepted
0
Hello Tim,
Have you seen our topic Integration with RadContextMenu as well as our demo demonstrating the described approach in action? You need to re-template the Pie series type in order to place a RadContextMenu instance as attached property in its template. Here is the default Pie template:
Greetings,
Evgenia
the Telerik team
Have you seen our topic Integration with RadContextMenu as well as our demo demonstrating the described approach in action? You need to re-template the Pie series type in order to place a RadContextMenu instance as attached property in its template. Here is the default Pie template:
<
Style
TargetType
=
"telerikCharting:Pie"
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerikCharting:Pie"
>
<
Canvas
x:Name
=
"PART_MainContainer"
>
<
Ellipse
Clip
=
"{TemplateBinding FigurePath}"
Width
=
"{TemplateBinding ItemActualWidth}"
Height
=
"{TemplateBinding ItemActualHeight}"
StrokeThickness
=
"0"
Style
=
"{TemplateBinding ItemStyle}"
/>
<
Path
x:Name
=
"PART_DefiningGeometry"
Data
=
"{TemplateBinding FigurePath2}"
Fill
=
"Transparent"
Style
=
"{TemplateBinding ItemStyle}"
/>
<
Ellipse
Clip
=
"{TemplateBinding FigurePath3}"
Fill
=
"{StaticResource PieMaskBrush}"
Width
=
"{TemplateBinding ItemActualWidth}"
Height
=
"{TemplateBinding ItemActualHeight}"
/>
<
Canvas.RenderTransform
>
<
TransformGroup
>
<
ScaleTransform
x:Name
=
"PART_AnimationTransform"
ScaleX
=
"0"
ScaleY
=
"0"
/>
</
TransformGroup
>
</
Canvas.RenderTransform
>
</
Canvas
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
Greetings,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Tim
Top achievements
Rank 1
answered on 21 Sep 2011, 04:28 PM
I want to have the same context menu for all items in the chart, but be able to know the selected item when the context menu is opened. Is there a simpler way than the above example?
It would seem like there is a way to get the DataPoint (if any) using RadContextMenu.GetClickedElement<>?
Thanks,
Tim
It would seem like there is a way to get the DataPoint (if any) using RadContextMenu.GetClickedElement<>?
Thanks,
Tim
0
Tim
Top achievements
Rank 1
answered on 22 Sep 2011, 10:58 PM
I got this to pop-up to ContextMenu, but how do I get the DataPoint (if any) of the item clicked? GetClickedElement?
0
Hello Tim,
To get the DataPoint of the clicked Bar you should handle the RadContextMenu_Opened event and use the GetClickedElement<T>() method:
Best wishes,
Evgenia
the Telerik team
To get the DataPoint of the clicked Bar you should handle the RadContextMenu_Opened event and use the GetClickedElement<T>() method:
RadContextMenu menu = (RadContextMenu)sender;
Bar clickedBar = menu.GetClickedElement<
Bar
>();
double clickedBarYValue = clickedBar.DataPoint.YValue;
Best wishes,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>