I have a wpf form which contains a datagrid. 1 of the columns in the datagrid is of type combobox. There are 1000's of items in the ItemsSource property of the combo-box. Hence it takes significant amount of time to display the values when the arrow besides the combo-box (rendering issue, I believe) is clicked. How can we make the combo-box display the items faster, virtually with no lag?
Try putting this onto your combobox. Rather than loading all of the items at once, this should make it load them as you view them.
For inside a datagrid, i always use a DataGridTemplateColumn for my combobox columns:
<DataGridTemplateColumn Header="My Combo Column">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Margin="0" ItemsSource="{Binding Path=DataContext.MyCollection, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
SelectedItem="{Binding Path=Item.Property, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Width=250 VirtualizingStackPanel.VirtualizationMode="Recycling" CanHorizontallyScroll="True"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With