Hi,
I'm trying to add a contextual menu to a MapPathView and I encountered some problems.
Here's what I have :
DataTemplate:
<DataTemplate x:Key="ZoneTemplate" DataType="ZoneViewModel">
<telerik:MapPathView>
<telerik:MapPathView.Data>
<.../>
</telerik:MapPathView.Data>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Header="Remove" Command="{Binding DataContext.RemoveZoneCommand, Source={x:Reference parentControl}}" CommandParameter="{Binding}"/>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:MapPathView>
</DataTemplate>
VisualizationLayer:
<telerik:VisualizationLayer UseDefaultPropertyAccessor="False" UseBitmapCache="False"
ItemsSource="{Binding Path=CurrentZones}" ItemTemplate="{StaticResource ZoneTemplate}"
MapShapeVisualizationCreated="OnVisualizationCreated" MapShapeVisualizationRemoved="OnVisualizationRemoved">
<telerik:VisualizationLayer.ShapeFill>
<telerik:MapShapeFill Fill="Blue" StrokeThickness="1" Stroke="Red" />
</telerik:VisualizationLayer.ShapeFill>
</telerik:VisualizationLayer>
VisualizationCreatedEvent:
private void OnVisualizationCreated(object sender, MapShapeOperationEventArgs e)
{
if (e.Visualization != null)
{
var dataContext = e.Data.Wrapper.DataContext as ZoneViewModel;
if (dataContext != null)
{
...
var contextMenu = RadContextMenu.GetContextMenu(e.Data.Wrapper);
RadContextMenu.SetContextMenu(e.Visualization, contextMenu);
contextMenu.DataContext = dataContext;
}
}
}
The contextual menu shows as expected, but the command parameter is not a ZoneViewModel as I expected, it's a PathData.
Do you have any idea of what is the problem ?
Thank you!
Etienne
I'm trying to add a contextual menu to a MapPathView and I encountered some problems.
Here's what I have :
DataTemplate:
<DataTemplate x:Key="ZoneTemplate" DataType="ZoneViewModel">
<telerik:MapPathView>
<telerik:MapPathView.Data>
<.../>
</telerik:MapPathView.Data>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Header="Remove" Command="{Binding DataContext.RemoveZoneCommand, Source={x:Reference parentControl}}" CommandParameter="{Binding}"/>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:MapPathView>
</DataTemplate>
VisualizationLayer:
<telerik:VisualizationLayer UseDefaultPropertyAccessor="False" UseBitmapCache="False"
ItemsSource="{Binding Path=CurrentZones}" ItemTemplate="{StaticResource ZoneTemplate}"
MapShapeVisualizationCreated="OnVisualizationCreated" MapShapeVisualizationRemoved="OnVisualizationRemoved">
<telerik:VisualizationLayer.ShapeFill>
<telerik:MapShapeFill Fill="Blue" StrokeThickness="1" Stroke="Red" />
</telerik:VisualizationLayer.ShapeFill>
</telerik:VisualizationLayer>
VisualizationCreatedEvent:
private void OnVisualizationCreated(object sender, MapShapeOperationEventArgs e)
{
if (e.Visualization != null)
{
var dataContext = e.Data.Wrapper.DataContext as ZoneViewModel;
if (dataContext != null)
{
...
var contextMenu = RadContextMenu.GetContextMenu(e.Data.Wrapper);
RadContextMenu.SetContextMenu(e.Visualization, contextMenu);
contextMenu.DataContext = dataContext;
}
}
}
The contextual menu shows as expected, but the command parameter is not a ZoneViewModel as I expected, it's a PathData.
Do you have any idea of what is the problem ?
Thank you!
Etienne