我正在开发一个 Windows 8 应用程序 (C#/XAML)。其中一个要求是在 DataGrid 中加载一组单词,我们在这里使用语义缩放选项。
当集合有超过 1500 个项目时,应用程序挂起并给出以下错误:
+Exception {“没有足够的配额来处理这个命令。(来自 HRESULT 的异常:0x80070718)”} System.Exception
使用的一些代码:
_collection = _readDictionary.GetModeDetailsForModeDetails(modeId);
var query = from item in _collection
orderby (item.WordName.ToLower())
group item by item.WordName[0].ToString().ToUpper() into g
select new { GroupName = g.Key.ToString().ToUpper(), Items = g };
foreach (var g in query)
{
GroupInfoList<Words> info = new GroupInfoList<Words>();
info.Key = g.GroupName;
foreach (var item in g.Items)
{
info.Add(item);
}
groups.Add(info);
}
bindGroupData.Source = groups;
(semanticZoom.ZoomedOutView as ListViewBase).ItemsSource = bindGroupData.View.CollectionGroups;
这是 XAML 代码:
<SemanticZoom x:Name="semanticZoom" VerticalAlignment="Bottom" >
<SemanticZoom.ZoomedOutView>
<GridView ScrollViewer.IsHorizontalScrollChainingEnabled="False" VerticalAlignment="Top" HorizontalAlignment="Left">
<GridView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Group.Key}" FontFamily="Segoe UI Light" Foreground="Red" FontSize="24"/>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid ItemWidth="75" ItemHeight="75" MaximumRowsOrColumns="5" VerticalChildrenAlignment="Center" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="Margin" Value="4" />
<Setter Property="Padding" Value="10" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</GridView.ItemContainerStyle>
</GridView>
</SemanticZoom.ZoomedOutView>
<SemanticZoom.ZoomedInView>
<GridView x:Name="GrdViewWord" SelectionMode="Multiple" ItemsSource="{Binding Source={StaticResource bindGroupData}}" ItemClick="GrdViewWord_ItemClick" SelectionChanged="GrdViewWord_SelectionChanged" Background="#FFE2E2E2" Height="396" VerticalAlignment="Top" >
<!-- ItemContainerStyle="{StaticResource GridViewItemStyle}" -->
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<!--<WrapGrid Orientation="Vertical" Background="{Binding BG}"/>-->
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="20" Width="75" >
<TextBlock Text="{Binding WordName}" Tag="{Binding WordID}" FontFamily="Segoe UI" FontSize="12" Margin="5,5,0,0" Foreground="Black" HorizontalAlignment="Left" Height="20" Padding="0"/>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="10">
<!--Background="{StaticResource ApplicationPageBackgroundThemeBrush}"-->
<TextBlock Text='{Binding Key}' FontSize="25" Foreground="Red" Margin="5" />
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Height="300" />
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
</SemanticZoom.ZoomedInView>
</SemanticZoom>
有人可以帮我解决这个问题吗?