C# WPF Dynamically events to array of buttons -


i know how make array of buttons, every button specific content, location , important action. knowledge way this:

for (int = 0; < n; i++) {                  _arr[i] = new button();     _arr[i].height = 25;     _arr[i].width = 25;     _arr[i].content = convert.tostring(randomnumber);      _arr[i].margin = new thickness(30,0,150,0);     _arr[i].click += (a, b) =>     {              }  } 

so question is: there better way this?

you can create class mybutton hold width, height, content, isdefault , other things may consider useful. put itemscontrol control, bind itemssource list<mybutton> , can style itemspanel apply datatemplate. action can bound via command each button class or can have 1 action inside check button has been pressed , react.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -