ComboBox中Items太多而导致加载过慢

虚化解决加载过慢

      <ComboBox x:Name="comboboxFontList"
                  VerticalAlignment="Top">
              <ComboBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel />
                </ItemsPanelTemplate>
            </ComboBox.ItemsPanel>
        </ComboBox>

避免SelectionChanged事件的第一次执行

private void ComboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (e.RemovedItems.Count > 0)
    {
        if (ComboBox1.SelectedItem is DemoDto item)
        {
            // TODO
        }
    } 
}
原文地址:https://www.cnblogs.com/wesson2019-blog/p/13132243.html