c# - Unable to delete a polygon on a bing Map Wpf control, cast exception -


I am using WP map control WPF

I add some polygons like this.

  polygon Place = DrySacerral (OLOC, DRDS); Polygon Tag = "circle"; MyMapUserControl.MyMap.Children.Add (polygon);   

Also my polygon is displaying correctly

Now, I can (i be severals polygon, that is why I use a tag I want to delete this polygon: "circle"), I tried this:

  on polygonToDelete = MyMapUserControl.MyMap .Children .OfType & LT; MapPolygon & gt; (). Where (P => (MapPolygon) p. .ag = "Circle"); MyMapUserControl.MyMap.Children.Remove ((UIElement) polygonToDelete);   

I have an exception with a cast error.

Anyone please help me coud?

Regards,

look at a break point using the check For what value the polygonToDelete object is, it first invokes the system to remove it. Is it a collection of a size or shape? I suspect that this is a collection of shapes and you have to first catch one, or have to convert your object through list and loop through each item and remove it from the map.

Try something like this:

  at polygonToDelete = MyMap.Children.OfType & LT; MapPolygon & gt; (). Where (P => (MapPolygon) P) .ag == "circle"). ToList (); Forchach (YRP in Polygon Telodile) {MyMap.Children.Remove (p); }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -