how set buttons name when created in c# can call later?
i have a list of strings (commands).
i loop on create button each item in list.
       commands.foreach(delegate (string i)         {               button button = new button()             {                 name = i,                 tag = i,                 maxwidth = 50,                 maxheight = 50,                 borderbrush = null             };               button.click += new routedeventhandler(button_click);             this.grid.children.add(button);              uri resourceuri = new uri("led_off.png", urikind.relative);             streamresourceinfo streaminfo = application.getresourcestream(resourceuri);              bitmapframe temp = bitmapframe.create(streaminfo.stream);             var brush = new imagebrush();             brush.imagesource = temp;              button.background = brush;          }); this loop works fine until add line  name = i
i in spot these buttons created , need change of there ground images. there better way call them there name?
name should valid string: try name = "button" + i.tostring() (fyi, button name cannot "1", it's invalid name). also, tag =i.tostring(). hope may help
Comments
Post a Comment