Wpf dynamic design with Grid and data binding -
i creating dynamic ui using code.i adding grid page using loop,in multiple rows , 4 columns,so takes time load ui on page.i want load each child grid lazily, don't know how it, please help. here xaml file
<scrollviewer grid.row="1" horizontalalignment="stretch" verticalalignment="stretch" cancontentscroll="true" horizontalscrollbarvisibility="auto" verticalscrollbarvisibility="auto" margin="0 0 0 0"> <grid x:name="maingrid" horizontalalignment="stretch" verticalalignment="top" margin="10" width="auto"> </grid> </scrollviewer>
and pseudo code .cs file
for (int column = 0; column < dsmacdtls.tables[0].rows.count; column++) { grid = new grid(); grid.width = 108; grid.height = 108; if (column % 4 == 0) { maingrid.rowdefinitions.add(new rowdefinition()); } else { maingrid.rowdefinitions.add(new rowdefinition()); } box = new checkbox(); textblock tb = new textblock(); tb.text = "abcd"; box.content = tb; grid.children.add(box); imagebrush mybrush = new imagebrush(); image = new image(); image.source = new bitmapimage(new uri("abcd.png")); grid.background = mybrush; grid.setcolumn(grid, 0); grid.setrow(grid, i); border br = new border(); br.borderthickness = new thickness(1); br.borderbrush = new solidcolorbrush(colors.gray); grid.setcolumn(br, 0); grid.setrow(br, rownumberofmachine); br.width = 108; br.height = 108; grid.children.add(br); maingrid.children.add(grid); }
Comments
Post a Comment