Hello,
This is a matter of accessing parent class variables.
Page elements are private variables after they are named in the XAML of the parent page, so you can't manipulate them directly in the child page.
<Grid x:Name="testGrid">
In this case, the easiest way to do this is to set up a public variable to make this control available to external access.
public Grid gridView { get; set; }
public MainPage()
{
InitializeComponent();
gridView = testGrid;
}
After that, you can call this control in a class that inherits this page.
public NewPage1()
{
InitializeComponent();
this.gridView.AddRowDefinition(new RowDefinition());
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.