I can create a new element of type Page
in code behind, but I want to add children elements of type UIElement
as I would to a Grid
like: myGrid.Children.Add(myUIElement);
I don't have the Children
property and setting the Content
property does not work.
How can I achieve this?
UPDATE:
This is what I have so far, but does not work:
Page myNewPage = new Page();
Grid myGrid = new Grid();
TextBlock myText = new TextBlock();
myText.Text = "I am a TextBlock!";
myGrid.Children.Add(myText);
myNewPage.Content = myGrid;
Frame.Navigate(myNewPage.GetType());