我们知道ListBox的ItemsPanelTemplate是VirtualizingStackPanel。我为我的ListBox定义了一个Style。 ListBox虚拟化无法工作。我能做什么?Windows Phone风格使ListBox的虚拟化禁用。如何恢复虚拟化?
<Style x:Key="ListBoxStyle" TargetType="ListBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<ScrollViewer x:Name="ScrollViewer"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Foreground="{TemplateBinding Foreground}"
Padding="{TemplateBinding Padding}">
<StackPanel>
<ItemsPresenter/>
<HyperlinkButton Content="Add More"
FontSize="25"
Grid.Row="1"
Name="hybtnAddMerchant"
Click="hybtnAddMerchant_Click"
VerticalAlignment="Bottom"/>
</StackPanel>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
变化到,该项目无法正常工作。 –
2012-01-13 02:25:38