WPF ExpressionDark VirtualizingStackPanel issue

28 Sep

WPF Themes are a nice feature, if they have no errors. Unfortunaterly by using one of the WPF Template you run in issue if you want to display large data sets, because the ListBox, Combobox ect have some problems with virtualizing data. This problem only occurs on these Template, because e.g. of following code piece:

<Style TargetType="{x:Type ListBox}">
    <Setter Property="Template">
            <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}"
                               BorderThickness="{TemplateBinding BorderThickness}"
                               Background="{DynamicResource ControlBackgroundBrush}" />
                    <ScrollViewer Margin="1" Style="{DynamicResource NuclearScrollViewer}"
                               Focusable="false" Background="{x:Null}">
                        <StackPanel Margin="1,1,1,1" IsItemsHost="true" />
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Background" TargetName="Border"
                               Value="{DynamicResource DisabledBackgroundBrush}"  />
                        <Setter Property="BorderBrush" TargetName="Border"
                               Value="{DynamicResource DisabledBorderBrush}"  />
                    <Trigger Property="IsGrouping" Value="true">
                        <Setter Property="ScrollViewer.CanContentScroll" Value="false" />

If you replace the StackPanel in the highlighted line 13 with VirtualizingStackPanel the virtualization will work.
The only problem is if you deactivate the virtualizing by calling VirtualizingStackPanel.IsVirtualizing=”False”

Leave a comment

Posted by on September 28, 2010 in C-Sharp, WPF


Tags: ,

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: