Add Extra Row in datagrid at runtime in silverlight


Introduction :

This blog shows how we can add extra row at runtime using loadingRow event in silverlight.
we can add rows at runtime using LoadingRow event in silverlight.
Example :
 public MainPage()
 {
   dataGrid1.LoadingRow += new EventHandler<DataGridRowEventArgs>(dataGrid1_LoadingRow);
 }
 void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)
  {
   e.Row.Header = e.Row.GetIndex() + 1;
  }

Output looks like as following.
The Red mark is the row which added in datagrid.

datar.JPG

We can also increase their indexing like,

e.Row.Header = e.Row.GetIndex() + 10;

Output.

gridrow.JPG

We can set the style for this row in datagrid as below.

e.Row.HeaderStyle = (Style)Application.Current.Resources["myrow"];

Thanks.
Ebook Download
View all
Learn
View all