如何解决Xamarin.Forms Form.Children.Add for ContentPage
我想要一些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 举报,一经查实,本站将立刻删除。