Xamarin表单动态添加页面/视图

oOM*_*lon 2 c# xaml view visual-studio xamarin.forms

我想知道是否可以从用户的角度动态添加新的页面/视图?

现在我有一个汉堡菜单,我希望能够添加一个使用特定布局页面的新页面.

有点像在网站CMS中添加新页面时的情况.

提前致谢!!

Jas*_*son 5

var page = new ContentPage();
page.Title = "My Page";
var content = new StackLayout();
// add content controls to layout here
// you could prompt the user for input - ie, how many buttons, or labels, etc
// and populate the stack accordingly
content.Children.Add(...);
page.Content = content;
Run Code Online (Sandbox Code Playgroud)

您还可以在菜单的数据源中添加指向此新页面的链接,以便它显示在菜单中