I have a silverlight form where in i am populating a datagrid in the constructor of the form, below is the code…
public partial class ManageArtists : UserControl
{
ChinookDomainContext cdContext = new ChinookDomainContext();
public ManageArtists()
{
InitializeComponent();
cdContext.Load(cdContext.GetArtistsQuery());
dpArtistPager.Source = cdContext.Artists.OrderBy(artist => artist.Name);
dgArtistList.ItemsSource = cdContext.Artists.OrderBy(artist => artist.Name);
}
}
Now the problem is….Even though the data is loaded in the grid it does not show anything until i click on the Header fields of the grid. I dont understand why is this happening ??
can someone explain me whats happening !!
thank you
In this line –
you’ll find that your
ItemsSourceis being set to an instance ofIOrderedEnumerable,..which doesn’t support property changed notification.To fix this quickly and easily wrap that collection in an
ObservableCollectionand your data should display correctly.HTH