I'm trying to make an Appli开发者_JAVA技巧cationBarMenuItem that, when clicked, switches my bing map between RoadMode and AerialMode. my pseudocode looks something like this:
private void changeMap_Click(object sender, EventArgs e)
{
if(map1.Mode == RoadMode)
map1.Mode = new Microsoft.Phone.Controls.Maps.AerialMode();
else
map1.Mode = new Microsoft.Phone.Controls.Maps.RoadMode();
}
However, it says I cannot use RoadMode, which is a 'type', like a variable. Does anyone have a way around this?
Because RoadMode is a class and you are trying to compare class to an object.
Try (edit)
if(map1.Mode is RoadMode)
精彩评论