Search code examples
c#wpfwpfdatagrid

datagridview itemsource is populated but not displaying?


Only column names are showing but rows are not showing in datagridview in WPF. I have tried putting the autogeneratecolumns="true" in the datagridview but getting no luck. I have debugged and checked the datatable have 2 rows but not displaying

<StackPanel Orientation="Horizontal"> 
    <DataGrid x:Name="GridViewProducts" Margin="80,30,0,0" 
    AutoGenerateColumns="True" BorderThickness="12" 
    BorderBrush="PaleTurquoise" ItemsSource="{Binding}" Height="200" Width="745" /> 
</StackPanel>

Solution

  • Probably item source does not have data when window is loaded - which is why grid only shows column headers only.

    Also exploring around observable collection is worth.