Xaml 配额不足,无法处理此命令。用于网格的windows 8 metro应用程序(不用于GRIDVIEW)中的(HRESULT:0x80070718的异常)
我试图通过UI在网格中生成动态控件,在UI中动态指定控件的大小。当生成超过1500个控件时,它抛出此错误,没有足够的配额可用于处理此命令。来自HRESULT的异常:0x80070718。我已经看到了gridview的一些解决方案,但我使用的是GRID,所以对我没有好处 请让我知道 提前谢谢Xaml 配额不足,无法处理此命令。用于网格的windows 8 metro应用程序(不用于GRIDVIEW)中的(HRESULT:0x80070718的异常),xaml,windows-8,grid,microsoft-metro,winrt-xaml,Xaml,Windows 8,Grid,Microsoft Metro,Winrt Xaml,我试图通过UI在网格中生成动态控件,在UI中动态指定控件的大小。当生成超过1500个控件时,它抛出此错误,没有足够的配额可用于处理此命令。来自HRESULT的异常:0x80070718。我已经看到了gridview的一些解决方案,但我使用的是GRID,所以对我没有好处 请让我知道 提前谢谢 <ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto"
<ScrollViewer HorizontalScrollMode="Auto"
HorizontalScrollBarVisibility="Auto"
VerticalScrollMode="Auto"
VerticalScrollBarVisibility="Auto" Margin="232,10,267,0" Grid.Row="1">
<Grid Name="dynamicgrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="LightBlue" Height="Auto" Width="Auto" Grid.Row="1"/>
</ScrollViewer>
C# code
try
{
MainPage mainpage = (MainPage)e.Parameter;
buttons = Convert.ToInt32(mainpage.buttonsize);
textblock = Convert.ToInt32(mainpage.txtBlocksize);
textbox = Convert.ToInt32(mainpage.txtBoxsize);
rows = Convert.ToInt32(mainpage.rows);
buttonwidth = Convert.ToInt32(mainpage.buttonwidth);
textblockwidth = Convert.ToInt32(mainpage.txtBlockwidth);
textboxwidth = Convert.ToInt32(mainpage.txtBoxwidth);
grdcolumn = buttons + textblock + textbox;
for (int i = 0; i < rows; i++)
{
RowDefinition rowDef = new RowDefinition();
rowDef.Height = new GridLength(200, GridUnitType.Auto);
dynamicgrid.RowDefinitions.Add(rowDef);
}
for (int j = 0; j < grdcolumn; j++) //need to mention
{
ColumnDefinition colDef1 = new ColumnDefinition();
colDef1.Width = new GridLength(100, GridUnitType.Auto);
dynamicgrid.ColumnDefinitions.Add(colDef1);
}
for (textboxcolumncount = 0; textboxcolumncount < textbox; textboxcolumncount++)
{
for (int i = 0; i < rows; i++)//textbox
{
TextBox txtbox = new TextBox();
txtbox.SetValue(TextBox.TextProperty, "txtbox" + i.ToString());
txtbox.Width = textboxwidth;
txtbox.Height = 50;
txtbox.SetValue(Grid.ColumnProperty, textboxcolumncount);
txtbox.SetValue(Grid.RowProperty, i);
dynamicgrid.Children.Add(txtbox);
dynamicgrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
}
}
textboxcolumncount = textbox;
for (textblockcolumncount = textboxcolumncount; textblockcolumncount < (grdcolumn - (buttons)); textblockcolumncount++)
{
for (int i = 0; i < rows; i++)
{
TextBlock txtblock = new TextBlock();
txtblock.SetValue(TextBlock.NameProperty, "txtblock" + i.ToString());
txtblock.Width = textblockwidth;
txtblock.Height = 50;
txtblock.SetValue(Grid.ColumnProperty, textblockcolumncount);
txtblock.SetValue(Grid.RowProperty, i);
txtblock.Text = "TextBlock" + i.ToString();
txtblock.Foreground = new SolidColorBrush(Colors.Black);
dynamicgrid.Children.Add(txtblock);
dynamicgrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
}
}
textboxcolumncount = textblockcolumncount;
for (buttonCoulmncount = textboxcolumncount; buttonCoulmncount < (grdcolumn); buttonCoulmncount++)
{
for (int i = 0; i < rows; i++) //button
{
Button btn = new Button();
btn.SetValue(Button.NameProperty, "btn" + i.ToString());
btn.Content = "Button" + i.ToString();
btn.Width = textboxwidth;
btn.Height = 50;
btn.Foreground = new SolidColorBrush(Colors.Black);
btn.SetValue(Grid.RowProperty, i);
btn.SetValue(Grid.ColumnProperty, buttonCoulmncount);
dynamicgrid.Children.Add(btn);
dynamicgrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
}
}
}
catch (Exception ex)
{
throw ex;
}
通过这个链接,我不确定这是否会解决你的问题,或者你会有一个想法
之后,您可以进行搜索。我还没有发现这样的问题。我猜您必须在系统上复制代码: 您使用网格/单元格是否有充分的理由?为什么不使用ItemsControl或GridView/ListView,然后允许您将数据模板放在那里,并让模板完成工作。你所看到的是大量的UI元素被创建,你正在达到windows PostMessage的限制,因为你没有虚拟化任何UI。