c# - DataGrid Columns created in xaml - how to fill programmatically? -


i have created datagrid in xaml. code this:

<datagrid x:name="mydatagrid" verticalalignment="top" height="305" margin="36,157,-36,0" autogeneratingcolumn="dgoverviewmain_autogeneratingcolumn" loaded="dgoverviewmain_loaded" mouseup="dgoverviewmain_mouseup" borderbrush="{x:null}" background="#ffedfdff">         <datagrid.columns>             <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="col1"/>             <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="col2"/>             <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="col3"/>         </datagrid.columns> </datagrid> 

now want add rows programmatically c#.

datarow temprow = dt_source.rows[1];   //get row datatable mydatagrid.items.add(temprow);         //insert temprow mydatagrid 

temprow.itemsarray containing data, line obove generates blank rows.

what doing wrong?

your <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="col1"/> not define should displayed in contents. therefore nothing bound each cell.

by having binding="{x:null}" saying want blank.

replace binding="{binding columnname}"


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -