private void DoWork()
{
Canvas CnMapField = new Canvas();
Image[] images = CopyFrom<Image>(CnMapField.Children);
foreach (Image img in images)
{
if (img.Margin.Left == x)
CnMapField.Children.Remove(img);
}
}
private T[] CopyFrom<T>(UIElementCollection collection) where T : UIElement
{
var images = new List<T>(collection.Count);
images.AddRange(collection.Cast<T>());
return images.ToArray();
}