I have grid in a WPF window and a DataGrid control inside:
<Grid>
<DataGrid ItemsSource="{Binding AllAuthors}" />
</Grid>
AllAuthors
is an ObservableCollection<Author>
and Author
a simple class with only a few string properties. The collection is populated with around 40000 objects in code behind. The DataGrid opens quite quickly (after 1 sec) and navigation through the datagrid goes smooth and fast. The application has a memory load of 35 MB.
If I replace the code above by ...
<StackPanel>
<DataGrid ItemsSource="{Binding AllAuthors}" />
</StackPanel>
... the application runs with 100% CPU load and memory grows continuously up to 1,5 GB while the application is trying to display the DataGrid. Finally I receive an OutOfMemoryException
.
I'm WPF beginner and wondering now what's wrong here. (I'm using VS2010, .NET 4.0 and the built-in DataGrid control of WPF 4.0)
Thank you for help in advance!