400人の子供がいるCanvasがあります。それぞれの子は長方形であり、画像で埋められています。特定の画像を見つけたい場合、どうすればよいですか?
//My code to fill a rectangle
Image img = new Image();
img.Source = new BitmapImage(new Uri(@"hero.png", UriKind.Relative));
img.Margin = rec.Margin;
ImageBrush imgbrush = new ImageBrush();
imgbrush.ImageSource = img.Source;
rec.Fill = imgbrush;
//My attempt at finding that certain rectangle
foreach (Rectangle rec in canvas1.Children)
{
if (rec.Fill = ImageBrush.ImageSourceProperty) // I tried to compare the rectangle with the image's source
{
}
}