问题描述
我想要一些Content Pages,将其添加到MainPage类中。我使用SetLayout函数来做到这一点,该参数是ContentPage。如何将ContentPage像孩子一样停靠在我的ContentPage(MainPage)上? 我的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>
和MainPage.cs中的SetLayout函数
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;
}
在上面的函数中,我在Form.Children.Add上出错,因为这需要contentview,而不是contentpage。 我不想将ContentPage更改为ContentView,因为我想使用BackButton。
有什么主意吗?谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)