开发者

How do I dynamically add a control within a PanoramaItem?

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";
    Layout开发者_如何转开发Root.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?


The same way you added it to LayoutRoot:

Pan2.Children.Add(box);

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜