title: ComboBox style causes dropdown to be extremely slow
body: <p>I have ~ 800 items in my ItemsSource combobox, when I first open the ComboBox it takes A LONG time (1-3 seconds) to show the popup, as if its generating it to be shown, however, if I disable my style for ComboBox it shows almost instantly without any slowdown. I've tried everything I read online (VirtualizingStack panels everywhere, disable stylus support, touch support etc..) but I have no idea what is causing this slowdown. Below is my XAML code:</p>
  
  <pre><code>&lt;Style x:Key="FocusVisual"&gt;
    &lt;Setter Property="Control.Template"&gt;
      &lt;Setter.Value&gt;
        &lt;ControlTemplate&gt;
          &lt;Rectangle StrokeDashArray="1 2" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" Margin="2"/&gt;
        &lt;/ControlTemplate&gt;
      &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
  &lt;/Style&gt;
  &lt;Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}"&gt;
    &lt;Setter Property="OverridesDefaultStyle" Value="true"/&gt;
    &lt;Setter Property="IsTabStop" Value="false"/&gt;
    &lt;Setter Property="Focusable" Value="false"/&gt;
    &lt;Setter Property="ClickMode" Value="Press"/&gt;
    &lt;Setter Property="Template"&gt;
      &lt;Setter.Value&gt;
        &lt;ControlTemplate TargetType="{x:Type ToggleButton}"&gt;
          &lt;Border x:Name="templateRoot" SnapsToDevicePixels="true" Background="White" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="#e0e0e0"&gt;
            &lt;Border x:Name="splitBorder" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" SnapsToDevicePixels="true" Margin="0" HorizontalAlignment="Right" BorderThickness="1" BorderBrush="Transparent"&gt;
              &lt;Path x:Name="arrow" VerticalAlignment="Center" Margin="0" HorizontalAlignment="Center" Fill="Black" Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"/&gt;
            &lt;/Border&gt;&lt;/Border&gt;
            &lt;ControlTemplate.Triggers&gt;
              &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                &lt;Setter Property="Fill" TargetName="arrow" Value="#3498db"&gt;
              &lt;/Setter&gt;
            &lt;/Trigger&gt;
              &lt;Trigger Property="IsPressed" Value="True"&gt;
                &lt;Setter Property="BorderBrush" TargetName="templateRoot" Value="#3498db"&gt;
              &lt;/Setter&gt;
            &lt;/Trigger&gt;
          &lt;/ControlTemplate.Triggers&gt;
        &lt;/ControlTemplate&gt;
      &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
      &lt;ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}"&gt;
        &lt;Grid x:Name="templateRoot" SnapsToDevicePixels="true"&gt;
          &lt;Grid.ColumnDefinitions&gt;
            &lt;ColumnDefinition Width="*" /&gt;
            &lt;ColumnDefinition
                          MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling"&gt;
            &lt;Popup x:Name="PART_Popup" AllowsTransparency="false" Grid.ColumnSpan="2"
                         IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                         Margin="1" MaxHeight="160" MinHeight="0" Placement="Bottom" MinWidth="{TemplateBinding ActualWidth}" &gt;
              &lt;Border x:Name="dropDownBorder" BorderBrush="#e0e0e0" BorderThickness="1" Background="White"&gt;
                &lt;ScrollViewer x:Name="DropDownScrollViewer" &gt;
                  &lt;Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled"&gt;
                    &lt;Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top"
                                          Width="0"&gt;
                      &lt;Rectangle x:Name="opaqueRect"
                                                 Fill="{Binding Background, ElementName=dropDownBorder}"
                                                 Height="{Binding ActualHeight, ElementName=dropDownBorder}"
                                                 Width="{Binding ActualWidth, ElementName=dropDownBorder}" /&gt;
                    &lt;/Canvas&gt;
                    &lt;VirtualizingStackPanel  IsItemsHost="True" Orientation="Vertical" VirtualizationMode="Recycling" IsVirtualizing="True" x:Name="ItemsPresenter"
  
                                                  KeyboardNavigation.DirectionalNavigation="Contained"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"&gt;
                  &lt;/VirtualizingStackPanel&gt;
                &lt;/Grid&gt;
              &lt;/ScrollViewer&gt;
            &lt;/Border&gt;
          &lt;/Popup&gt;
        &lt;/VirtualizingStackPanel&gt;
          &lt;ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}" Grid.ColumnSpan="2"
                                IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                Style="{StaticResource ComboBoxToggleButton}" /&gt;
          &lt;ContentPresenter x:Name="contentPresenter"
                                    ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                    ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                    Content="{TemplateBinding SelectionBoxItem}"
                                    ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    IsHitTestVisible="false" Margin="{TemplateBinding Padding}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /&gt;
        &lt;/Grid&gt;
        &lt;ControlTemplate.Triggers&gt;
          &lt;Trigger Property="HasItems" Value="false"&gt;
            &lt;Setter Property="Height" TargetName="dropDownBorder" Value="95"/&gt;
          &lt;/Trigger&gt;
        &lt;/ControlTemplate.Triggers&gt;
      &lt;/ControlTemplate&gt;
    &lt;/Style&gt;
    &lt;Style TargetType="{x:Type ComboBox}"&gt;
      &lt;Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/&gt;
      &lt;Setter Property="Background" Value="White"/&gt;
      &lt;Setter Property="BorderBrush" Value="#e0e0e0"/&gt;
      &lt;Setter Property="Foreground" Value="Black"/&gt;
      &lt;Setter Property="BorderThickness" Value="1"/&gt;
      &lt;Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/&gt;
      &lt;Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/&gt;
      &lt;Setter Property="ScrollViewer.CanContentScroll" Value="true"/&gt;
      &lt;Setter Property="ScrollViewer.PanningMode" Value="None"/&gt;
      &lt;Setter Property="Stylus.IsFlicksEnabled" Value="False"/&gt;
      &lt;Setter Property="OverridesDefaultStyle" Value="True"&gt;
    &lt;/Setter&gt;
      &lt;Setter Property="Template" Value="{StaticResource ComboBoxTemplate}"/&gt;
    &lt;/Style&gt;
    &lt;Style TargetType="{x:Type ComboBoxItem}"&gt;
      &lt;Setter Property="OverridesDefaultStyle" Value="True"&gt;
    &lt;/Setter&gt;
      &lt;Setter Property="SnapsToDevicePixels" Value="true"/&gt;
      &lt;Setter Property="Width" Value="Auto"&gt;
    &lt;/Setter&gt;
      &lt;Setter Property="Template"&gt;
        &lt;Setter.Value&gt;
          &lt;ControlTemplate TargetType="ComboBoxItem"&gt;
            &lt;Border
                              Name="Border"
                              Padding="2"
                              SnapsToDevicePixels="true"&gt;
              &lt;VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling"&gt;
                &lt;ContentPresenter /&gt;
              &lt;/VirtualizingStackPanel&gt;
            &lt;/Border&gt;
            &lt;ControlTemplate.Triggers&gt;
              &lt;Trigger Property="IsHighlighted" Value="true"&gt;
                &lt;Setter TargetName="Border" Property="Background"
                                          Value="#f0f0f0" /&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="IsEnabled" Value="false"&gt;
                &lt;Setter Property="Foreground" Value="Gray" /&gt;
              &lt;/Trigger&gt;
            &lt;/ControlTemplate.Triggers&gt;
          &lt;/ControlTemplate&gt;
        &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
    &lt;/Style&gt;
  </code></pre>
  
  <p>And here is how I add it to my form..</p>
  
  <pre><code>&lt;ComboBox x:Name="GameCombobox"  Margin="20,0,18,0" Height="25" ItemsSource="{Binding Games, Mode=OneWay, Source={x:Static ui:Ui.Instance}}" SelectedValue="Name" IsEditable="False"&gt;
      &lt;ComboBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;VirtualizingStackPanel Orientation="Vertical" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" Height="45" Width="Auto"&gt;
                  &lt;Label FontFamily="Resources/Fonts/#Lato" FontSize="14px" Foreground="Black"   Content="{Binding Name}"/&gt;
                  &lt;VirtualizingStackPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.IsVirtualizing="True" Margin="0 -5 0 0" &gt;
                      &lt;Path Margin="5 5 0 0" Fill="Crimson"  Data="M 25 12 C 11.667228 12 1.25 24.34375 1.25 24.34375 A 1.0001 1.0001 0 0 0 1.25 25.65625 C 1.25 25.65625 11.667228 38 25 38 C 38.332772 38 48.75 25.65625 48.75 25.65625 A 1.0001 1.0001 0 0 0 48.75 24.34375 C 48.75 24.34375 38.332772 12 25 12 z M 25 14 C 27.627272 14 30.141915 14.544587 32.46875 15.375 C 34.032931 17.140338 35 19.450427 35 22 C 35 27.535732 30.535732 32 25 32 C 19.464268 32 15 27.535732 15 22 C 15 19.45074 15.935707 17.139242 17.5 15.375 C 19.834652 14.538846 22.362198 14 25 14 z M 14.1875 16.84375 C 13.439134 18.407614 13 20.155051 13 22 C 13 28.616268 18.383732 34 25 34 C 31.616268 34 37 28.616268 37 22 C 37 20.163179 36.580282 18.404914 35.84375 16.84375 C 41.492764 19.714987 45.555865 23.87765 46.59375 25 C 44.969234 26.756721 35.970973 36 25 36 C 14.029027 36 5.0307657 26.756721 3.40625 25 C 4.4456392 23.876024 8.5256535 19.715345 14.1875 16.84375 z M 25 17 C 22.238576 17 20 19.238576 20 22 C 20 24.761424 22.238576 27 25 27 C 27.761424 27 30 24.761424 30 22 C 30 19.238576 27.761424 17 25 17 z"&gt;
                          &lt;Path.RenderTransform&gt;
                              &lt;ScaleTransform ScaleY="0.3" ScaleX="0.3"/&gt;
                          &lt;/Path.RenderTransform&gt;
                      &lt;/Path&gt;
                      &lt;Label Margin="-30 0 0 0" FontFamily="Resources/Fonts/#Lato" FontSize="14px" Foreground="#959699"  Content="{Binding Players}"/&gt;
                  &lt;/VirtualizingStackPanel&gt;
              &lt;/VirtualizingStackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/ComboBox.ItemTemplate&gt;
      &lt;ComboBox.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling"&gt;&lt;/VirtualizingStackPanel&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ComboBox.ItemsPanel&gt;
  &lt;/ComboBox&gt;
  </code></pre>