I need to display a RadContextMenu when a user right-clicks on a pointmark on a line series. But the RadContextMenu always appears at (0,0), instead of the mouse-click location.
My ChartView has a LineSeriesDefinition that sets the PointMarkItemStyle as follows:
<
telerik:LineSeriesDefinition
EmptyPointBehavior
=
"Drop"
ShowItemLabels
=
"False"
ShowItemToolTips
=
"True"
PointMarkItemStyle
=
"{StaticResource AveragePointMarkStyle}"
>
</
telerik:LineSeriesDefinition
>
And the AveragePointMarkStyle is defined as follows:
<
Style
x:Key
=
"AveragePointMarkStyle"
TargetType
=
"telerik:PointMark"
>
<
Setter
Property
=
"Size"
Value
=
"7"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:PointMark"
>
<
Canvas
>
<
Path
x:Name
=
"PART_PointMarkPath"
Stretch
=
"Fill"
Width
=
"{TemplateBinding Size}"
Height
=
"{TemplateBinding Size}"
Style
=
"{TemplateBinding ShapeStyle}"
Canvas.Left
=
"{TemplateBinding PointMarkCanvasLeft}"
Canvas.Top
=
"{TemplateBinding PointMarkCanvasTop}"
Stroke
=
"{StaticResource PrimaryTargetLineBackground}"
Fill
=
"{StaticResource AverageLineBackground}"
Data
=
"{Binding DataItem.Note,Mode=OneWay,Converter={StaticResource NoteExistPathDataConverter}}"
>
<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
ItemsSource
=
"{Binding DataItem.MenuItems,Mode=OneWay}"
ItemClick
=
"OnContextMenuClick"
MaxWidth
=
"185"
Placement
=
"MousePoint"
MinWidth
=
"130"
Tag
=
"{Binding DataItem}"
>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>
</
Path
>
</
Canvas
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
This is all good, except that when I right-click on a point mark, the RadContextMenu opens in the (0,0) location of the screen, instead of where the right-click took place, which is unacceptable.
I tried adding
PlacementTarget="{Binding RelativeSource={RelativeSource Self}}"
to the definition of the RadContextMenu. This causes the context menu to appear in the correct location, but it now contains no menu items because this somehow stuff up the ItemsSource binding - binding simply does not take place. And the documentation for the PlacementTarget property is really bad.
Is this possible to make this work properly (i.e. the context menu appears in the correct place AND the ItemSource binds correctly) in a templated scenario?