Tuesday, May 8, 2012

Loop Through Datagrid in WPF (ItemSource is type Observable Collection)

Assuming the databinding source of WPF Datagrid is of type ObservableCollection
Code:
  var row = GetDataGridRows(dgScripts);  
  foreach (DataGridRow r in row)  
  {  
     CScriptsInfo info = (CScriptsInfo)r.Item;  
     if(info.prog_name.ToString().Contains(txtScriptName.Text.Trim().ToUpper()))  
     {  
        r.IsSelected = true;  
     }  
  }

0 comments:

Post a Comment