我创建了一个包含大约 1500 个元素的 ComboBox。这个 ComboBox 第一次非常慢,甚至用存储过程填充集合我该怎么办?
这是代码`
<ComboBox Name="cbMember" TextSearch.TextPath="MemberFullName" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" IsEditable="True" Height="23" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" Margin="5,0,0,0" ItemsSource="{Binding MemberCollection}" SelectedItem="{Binding Path=SelectedSearchMember,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" KeyDown="cbMember_KeyDown" DropDownClosed="cbMember_DropDownClosed" SelectionChanged="cbMember_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding MemberFullName}" VerticalAlignment="Center" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>`
并填写可观察的集合代码在这里
MemberCollection = new ObservableCollection<PROC_MembersList_Result>(_context.PROC_MembersCollectionList().Where(c => c.IsHide != null && (bool)c.IsHide == true));