c# - Fill TextBlock within a Button with database records -


lets have 10 rows in database table. want create 10 buttons , textblock inside buttons filled data rows. create 10 buttons , textblock inside here code

for (int = 0; < 10; i++)  {         button btn = new button();             style style = this.findresource("metronewbutton") style;             btn.style = style;             btn.width = 250;             btn.height = 80;             btn.name = "btnca" + i;             btn.flowdirection = flowdirection.lefttoright;             btn.horizontalalignment = horizontalalignment.left;             btn.verticalalignment = verticalalignment.top;               (int j = 0; j < 10; j++)                {                         grid gridcontent = new grid();                 gridcontent.width = 250;                 gridcontent.height = 80;                  textblock txtblock = new textblock();                 txtblock.name = "txtblock" + j;                 txtblock.textwrapping = textwrapping.wrap;                 txtblock.fontsize = 14;                 txtblock.fontweight = fontweights.bold;                 //txtblock1.flowdirection = flowdirection.righttoleft;                 txtblock.padding = new thickness(10, 20, 0, 0);                 txtblock.verticalalignment = verticalalignment.top;                 grid.setrow(txtblock, 0);                  gridcontent.children.add(txtblock);                 btn.content = gridcontent;                }    } 

okay , have list carries data database.i want distribute data text block, how put data in text block ?

i think, using itemscontrol proper itemtemplate better idea creating controls in loop. create list of objects representing data, bind itemscontrol(itemssource={binding your_path}), , set proper item template grid. after that, put itemscontrol inside button. if understood right, should solve problem.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -