c# - How do I find a certain Child image in a Canvas? -


i have canvas has 400 children. each of children rectangle , filled image. if want find image, how go doing that?

//my code fill 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 @ finding rectangle  foreach (rectangle rec in canvas1.children)         {             if (rec.fill = imagebrush.imagesourceproperty) // tried compare rectangle image's source             {              }                         } 

you may use names for every specific image using findname method

object wantednode = stackpanel.findname("dog"); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -