This question is locked. New answers and comments are not allowed.
In my xaml file,I have a RadMap control and a RadContextMenu control, I have Bind a BingMapProvider to the radmap Provider,
When click the Item of RadContextMenu control,I want to change the map's mapmode of the Provider.I have wrote this code,but it does not work, how can I do?
I have upload my test project to the skydrive:
the link:RadMapApp
https://skydrive.live.com/redir.aspx?cid=f0fb1c4281efe663&resid=F0FB1C4281EFE663!128&parid=F0FB1C4281EFE663!126&
authkey=!ACrMTRYYxSQcQbM
the code:
<Grid Background="White">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="RightMenu" cal:Message.Attach="[Event ItemClick]=[Action RightMenu($eventArgs)]">
<telerik:RadMenuItem Header="Road" />
<telerik:RadMenuItem Header="Aerial" />
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
<telerik:RadMap Name="Map"
Margin="0 0 0 0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
CommandBarVisibility="Collapsed"
MouseLocationIndicatorVisibility="Collapsed"
NavigationVisibility="Collapsed"
Provider="{Binding MapProvider}"
ScaleVisibility="Collapsed"
ZoomBarPresetsVisibility="Collapsed"
ZoomBarVisibility="Collapsed"
ZoomLevel="4" />
</Grid>
viewmodel:
private BingMapProvider mapProvider = new BingMapProvider(MapMode.Road, false, "AqKk5lc40_-hQY5SwkvonqQsX3Rj2b-tRN1u30tfJX8CuGqVYo0v_GPQ4kZHgHLx");
public BingMapProvider MapProvider
{
get { return mapProvider; }
set
{
mapProvider = value;
NotifyOfPropertyChange(() => MapProvider);
}
}
private string textValue = "test";
public string TextValue
{
get { return textValue; }
set
{
textValue = value;
NotifyOfPropertyChange(() => TextValue);
}
}
public void RightMenu(Telerik.Windows.RadRoutedEventArgs e)
{
string hearder = (e.OriginalSource as RadMenuItem).Header as string;
switch (hearder)
{
case "Road":
mapProvider = new BingMapProvider(MapMode.Road, false, "AqKk5lc40_-hQY5SwkvonqQsX3Rj2b-tRN1u30tfJX8CuGqVYo0v_GPQ4kZHgHLx");
textValue = "Road";
break;
case "Aerial":
mapProvider = new BingMapProvider(MapMode.Aerial, false, "AqKk5lc40_-hQY5SwkvonqQsX3Rj2b-tRN1u30tfJX8CuGqVYo0v_GPQ4kZHgHLx");
textValue = "Aerial";
break;
}
MessageBox.Show(TextValue);
}
When click the Item of RadContextMenu control,I want to change the map's mapmode of the Provider.I have wrote this code,but it does not work, how can I do?
I have upload my test project to the skydrive:
the link:RadMapApp
https://skydrive.live.com/redir.aspx?cid=f0fb1c4281efe663&resid=F0FB1C4281EFE663!128&parid=F0FB1C4281EFE663!126&
authkey=!ACrMTRYYxSQcQbM
the code:
<Grid Background="White">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="RightMenu" cal:Message.Attach="[Event ItemClick]=[Action RightMenu($eventArgs)]">
<telerik:RadMenuItem Header="Road" />
<telerik:RadMenuItem Header="Aerial" />
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
<telerik:RadMap Name="Map"
Margin="0 0 0 0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
CommandBarVisibility="Collapsed"
MouseLocationIndicatorVisibility="Collapsed"
NavigationVisibility="Collapsed"
Provider="{Binding MapProvider}"
ScaleVisibility="Collapsed"
ZoomBarPresetsVisibility="Collapsed"
ZoomBarVisibility="Collapsed"
ZoomLevel="4" />
</Grid>
viewmodel:
private BingMapProvider mapProvider = new BingMapProvider(MapMode.Road, false, "AqKk5lc40_-hQY5SwkvonqQsX3Rj2b-tRN1u30tfJX8CuGqVYo0v_GPQ4kZHgHLx");
public BingMapProvider MapProvider
{
get { return mapProvider; }
set
{
mapProvider = value;
NotifyOfPropertyChange(() => MapProvider);
}
}
private string textValue = "test";
public string TextValue
{
get { return textValue; }
set
{
textValue = value;
NotifyOfPropertyChange(() => TextValue);
}
}
public void RightMenu(Telerik.Windows.RadRoutedEventArgs e)
{
string hearder = (e.OriginalSource as RadMenuItem).Header as string;
switch (hearder)
{
case "Road":
mapProvider = new BingMapProvider(MapMode.Road, false, "AqKk5lc40_-hQY5SwkvonqQsX3Rj2b-tRN1u30tfJX8CuGqVYo0v_GPQ4kZHgHLx");
textValue = "Road";
break;
case "Aerial":
mapProvider = new BingMapProvider(MapMode.Aerial, false, "AqKk5lc40_-hQY5SwkvonqQsX3Rj2b-tRN1u30tfJX8CuGqVYo0v_GPQ4kZHgHLx");
textValue = "Aerial";
break;
}
MessageBox.Show(TextValue);
}