I'm experiencing some poor performance when I have a datagrid that has one or many combobox columns I see a degredation in performance around sorting the columns and scrolling up/down.
My itemsource is a generic.list(of myclass) and can contain anything from 7 to 200 items.
To work around this I created my own DataGridComboBoxFastColumn which is a copy of the existing class but using a textblock for the normal element rather than TextBlockComboBox class. This did the trick and performance is great.
However I do have a number of problems after implementing this new column class and wondered if anyone else had seen this problem and done anything about it. The type of problems I see are:-
When I have 100+ rows and scroll down to the bottom the new row has a value for the new column? Also when I page down the column values become out of sync. Pasting also causes problems with the code snippett below which can't find the new row index it returns
For Each lobjCell As DataGridCellInfo In Me.SelectedCells
If TypeOf lobjCell.Item Is DataRowView Then
' User the Cell.Item to work out the row in the grid, later we use the items(index) to do this.
Dim lobjDataRowView As DataRowView = DirectCast(lobjCell.Item, DataRowView)
Dim lintMinRowIndex As Integer = Items.IndexOf(lobjDataRowView)
My new class has the minor changes below to the original DataGridComboBoxColumn it inherits from DataGridColumn as well, I defined a new class called TextBlockFast which I create an instance of instead of TextBlockComboBox although I didn't implement the OnDataContextPropertyChanged...
could this be one of the reasons I'm seeing the problems above?
public class TextBlockFast : TextBlock
DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBlockFast), new FrameworkPropertyMetadata(typeof(TextBlockFast)));
KeyboardNavigation.IsTabStopProperty.OverrideMetadata(typeof(TextBlockFast), new FrameworkPropertyMetadata(false));
//DataContextProperty.OverrideMetadata(typeof(TextBlockFast), new FrameworkPropertyMetadata(OnDataContextPropertyChanged));
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
TextBlockFast textBox = new TextBlockFast();
ApplyStyle(/* isEditing = */ false, /* defaultToElementStyle = */ false, textBox);
ApplyBinding(TextBinding, textBox, TextBlock.TextProperty);