我正在 Build 一个应用程序,我在导航到该页面后在ActionBar中呈现 Headers 时遇到问题 . 由于ActionBar不能使用可观察的viewModel来设置title属性 .
-----xml-----
<Page.actionBar>
<ActionBar title="{{ name }}">
</ActionBar>
</Page.actionBar>
-------------
------js-----
exports.pageLoaded = function(args) {
page = args.object;
var navData = page.navigationContext;
viewModel.set("name",navData.name);
page.bindingContext = viewModel;
};
到目前为止我所看到的调试这个问题的是,当我关闭手机屏幕并打开它(刷新应用程序)后,操作栏 Headers 将呈现 .
找到答案(解决方法),
<ActionBar>
<ActionItem ios.systemIcon="12" android.systemIcon="ic_menu_search" tap="showSearch" />
<ActionItem android.systemIcon="ic_menu_moreoverflow" tap="logout" text="Logout" android.position="popup" />
<ActionBar.titleView>
<StackLayout orientation="horizontal">
<Label text="{{ name }}" />
<Image src="res://app_icon" />
</StackLayout>
</ActionBar.titleView>
1 回答
您需要在不同的页面事件中设置 Headers ,相当确定您应该在页面的
navigatedTo
事件中执行此操作 .有关页面导航事件的更多信息,请查看此博客文章Nathanael Anderson - FluentReports - page navigating order of events