如何在 PanoramaItem 中动态添加控件?

发布于 2024-11-26 20:12:46 字数 448 浏览 6 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情域 2024-12-03 20:12:46

与将其添加到 LayoutRoot 的方式相同:

Pan2.Children.Add(box);

假设 Pan2PanoramaItem 内的实际网格控件。

The same way you added it to LayoutRoot:

Pan2.Children.Add(box);

Given that Pan2 is an actual Grid control inside a PanoramaItem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文