I would like to have a few Content Pages , which I add in my MainPage class. I use SetLayout function to do that, which parameter is ContentPage. How to dock a ContentPage to my ContentPage( MainPage) as children please? My MainPage xaml:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyApp.MainPage"
x:Class="MyApp;assembly=App"
BackgroundColor="White">
<StackLayout x:Name="Form">
</StackLayout>
And SetLayout function in MainPage.cs
private void SetLayout(ContentPage page)
{
if (LastControl != null)
{
LastControl.IsEnabled = false;
Form.Children.Remove(LastControl);
Form.Children.Add(page);
}
else
{
Form.Children.Add(page);
}
page.IsVisible = true;
LastControl = page;
}
In function above I have error on Form.Children.Add, because this wants contentview, not contentpage. I dont want to change my ContentPage to ContentView, because I want to have working BackButton.
Any idea? Thanks