如何在 PanoramaItem 中动态添加控件?
我正在使用 Visual Studios 2010 制作 Windows Phone 7 应用程序,并且试图了解当用户按下特定按钮时如何在 PanoramaItem 的网格内动态创建复选框。
以下代码成功地将一个复选框添加到名为“Layout Root”的主网格中:
private void addItemButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
CheckBox box = new CheckBox();
box.Content = "Test Box";
LayoutRoot.Children.Add(box);
}
但是,我想将该复选框添加到特定位置,即 PanoramaItem 的网格(标题为“Pan2”)。有没有办法做到这一点,如果有的话,怎么做?
I am using Visual Studios 2010 to make a Windows Phone 7 app, and I'm trying to understand how to dynamically create a CheckBox within the grid of a PanoramaItem when the user pushes a specific button.
The following code successfully adds a check box to the main grid called "Layout Root":
private void addItemButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
CheckBox box = new CheckBox();
box.Content = "Test Box";
LayoutRoot.Children.Add(box);
}
However, I want to add the check box to a specific location, namely the grid of a PanoramaItem (titled "Pan2"). Is there a way to do that, and if so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与将其添加到 LayoutRoot 的方式相同:
假设
Pan2
是PanoramaItem
内的实际网格控件。The same way you added it to LayoutRoot:
Given that
Pan2
is an actual Grid control inside aPanoramaItem
.