【发布时间】:2013-05-27 02:16:49
【问题描述】:
因此,我正在尝试创建一个网格,该网格可以根据 Frame 的打开时间由 0 到 X 个项目动态填充。
我阅读了有关如何创建网格并在代码中添加到其中的 MSDN 文章: http://msdn.microsoft.com/en-us/library/ms752271.aspx
但是,我想在 XAML 中创建 Grid 并在代码中添加它。像这样的:
XAML:
<Grid x:Name="ManagePhotosContent" Grid.Row="1" Visibility="Visible">
<!-- to be filled in by code -->
</Grid>
在 C# 代码中,我正在做这样的事情:
rowDef = new RowDefinition();
ManagePhotosContent.RowDefinitions.Add(rowDef);
textBlock = new TextBlock();
// i is an incrementer
textBlock.Text = string.Format("The is iteration {0}, i);
ManagePhotosContent.SetRow(textBlock, i);
但是,SetRow 不是我在 XAML 中创建的 ManagePhotosContent 网格的可用函数或属性。此外,我无法看到如何将代码中的 RowDefinition 设置为 Height="*"。我在这里做错了吗?
【问题讨论】:
-
SetRow 不是 Grid 上的静态方法吗?
标签: xaml visual-studio-2012 grid windows-runtime