Only remove pushpins from a layer in Bing Map
2010-11-18
public void Clear()
{
List<UIElement> elementsToRemove = new List<UIElement>();
List<UIElement> pushpinToRemove = new List<UIElement>();
foreach (UIElement element in MyMap.Children)
{
if (element.GetType() == typeof(MapLayer))
{
MapLayer Lay = (MapLayer)element;
if (Lay.Name == "PushPinLayer")
{
foreach (UIElement p in Lay.Children)
{
if (p.GetType() == typeof(Pushpin))
{
pushpinToRemove.Add(p);
}
}
foreach (UIElement pin in pushpinToRemove)
{
Lay.Children.Remove(pin);
}
elementsToRemove.Add(Lay);
}
}
foreach (UIElement e in elementsToRemove)
{
MyMap.Children.Remove(e);
}
}
}
above code from Dinesh's Blog