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

时间:2016-05-16 19:48:04

标签: c# visual-studio xaml view xamarin.forms

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

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

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

提前致谢!!

1 个答案:

答案 0 :(得分: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;

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