I have a Windows Forms app, that has a single ElementHost containing a WPF UserControl... in my WPF, I have a VERY simple ListView:
<ListView Margin="4" ItemsSource="{Binding Notifications}">
<ListView.View>
<GridView>
<GridViewColumn Header="FirstName" DisplayMemberBinding="{Binding FirstName}" />
<GridViewColumn Header="LastName" DisplayMemberBinding="{Binding LastName}" />
<GridViewColumn Header="Address" DisplayMemberBinding="{Binding Address}" />
<GridViewColumn Header="City" DisplayMemberBinding="{Binding City}" />
<GridViewColumn Header="State" DisplayMemberBinding="{Binding State}" />
<GridViewColumn Header="Zip" DisplayMemberBinding="{Binding Zip}" />
</GridView>
</ListView.View>
</ListView>
If my source has 10 items, the form loads in less than one second. If my source has 1000 items, it takes 7 seconds!!! My timer is ONLY taking the loading into account (not how much time it takes to get the items).
So my question is:
Is using an ElementHost a performance nightmare?
Is WPF DataBinding a performance nightmare?
Is the ListView a piece of crap? (btw, same results with the WPFToolkit's DataGrid)?
Use virtualization
<ListView ItemsSource="{BindingNames}"Name="lv">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<!--<StackPanel/>
If StackPanel was used, the memory consumed was over 2GB and dead slow.
-->
<VirtualizingStackPanel>
<!--Memory footprint is only 200 mb-->
</VirtualizingStackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>