C# 在Windows 8.1应用商店应用程序中设置VirtualzingStackPanel.is虚拟化
我在Windows8.1商店应用程序中有一个XAML页面。我为ListView设置了数据上下文,但最初将其折叠。我试图做的是在使ListView可见之前切换ListView中某些元素的可见性。但它不会加载它们,除非它变得可见。因此,为了强制它加载项目,我尝试将“IsVirtualization”设置为false,这样我就不必担心它(而且我不介意性能受到影响,因为我不会有那么多项目)。但对于我所看到的所有例子,我得到的只是C# 在Windows 8.1应用商店应用程序中设置VirtualzingStackPanel.is虚拟化,c#,xaml,windows-store-apps,C#,Xaml,Windows Store Apps,我在Windows8.1商店应用程序中有一个XAML页面。我为ListView设置了数据上下文,但最初将其折叠。我试图做的是在使ListView可见之前切换ListView中某些元素的可见性。但它不会加载它们,除非它变得可见。因此,为了强制它加载项目,我尝试将“IsVirtualization”设置为false,这样我就不必担心它(而且我不介意性能受到影响,因为我不会有那么多项目)。但对于我所看到的所有例子,我得到的只是 The property "IsVirtualizing" does no
The property "IsVirtualizing" does not have an accessible setter.
不知道这里发生了什么
下面是相关的代码片段,其他内容已被剥离
<common:LayoutAwarePage
x:Class="FlashMe.DeckView"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FlashMe"
xmlns:common="using:FlashMe.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
>
<ScrollViewer x:Name="deckScrollViewer" Grid.Row="1" VerticalScrollMode="Disabled" HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" Margin="0,15,0,0">
<StackPanel x:Name="deckStackPanel" Orientation="Horizontal">
<Grid Width="100" x:Name="MarginBuffer" />
<ListView x:Name="cardsListViewDisplay" Visibility="Collapsed" SelectionMode="None" Width="500" ItemsSource="{Binding Path=FlashCardsAsList}" VirtualizingStackPanel.IsVirtualizing="False">
<ListView.ItemTemplate>
<DataTemplate>
<Border>
<StackPanel Orientation="Vertical" Width="490" Height="400" RightTapped="FlashCardRightClicked">
<Grid Width="490" Height="200" Background="Gainsboro">
<TextBlock Text="{Binding Path=Front}"
Foreground="Black"
Style="{StaticResource GroupHeaderTextStyle}"
Margin="4,0,4,4"
FontWeight="SemiBold"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
MaxWidth="410"/>
</Grid>
<Grid Width="500" Height="200" Background="{Binding ElementName=deckStackPanel, Path=DataContext.DeckColorBrush}">
<TextBlock Text="{Binding Path=Back}"
Foreground="White"
Style="{StaticResource GroupHeaderTextStyle}"
Margin="4,0,0,4"
FontWeight="SemiBold"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
MaxWidth="410"/>
</Grid>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</ScrollViewer>
</common:LayoutAwarePage>
在Windows应用商店应用程序中,
IsVirtualization
属性是只读的
从MSDN页面的备注部分:
虚拟化StackPanel.IsVirtualization是一个非典型的附加属性
因为它没有集访问器,因此它不是真正的XAML
带有标记用法的附加属性。相反
虚拟化StackPanel.isVirtualization起到了哨兵的作用
子元素可以查询虚拟化StackPanel父元素,以及
确定是否正在使用虚拟化
在阅读MSDN页面时,我完全错过了该部分。谢谢