public void BodyGet() { adata = new ObservableCollection <AccountsData>(); List <XElement> l = _viewmodel.GridValidation(); List <XElement> lst = l.Where(x => x.Attribute("Sno").Value.Equals(_viewmodel.ad.Sno)).ToList(); if (lst != null && lst.Count != 0) { foreach (XElement x in lst) { AccountsData ad = new AccountsData(); //ad.Sno = x.Attribute("Sno").Value; removed the control from design ad.TaxClass = x.Attribute("TaxClass").Value; ad.TaxRate = decimal.Parse(x.Attribute("TaxRate").Value); ad.Narration = x.Attribute("Narration").Value; adata.Add(ad); } } else { Clear(); } dgBody.ItemsSource = adata; }