1 回答

TA貢獻(xiàn)2036條經(jīng)驗(yàn) 獲得超8個(gè)贊
將頁面?zhèn)鬟f給Navigate function將使導(dǎo)航功能更加通用。下次您想導(dǎo)航新頁面時(shí),只需將新頁面?zhèn)鬟f給它即可。
private void JournalSelected(object sender, SelectedItemChangedEventArgs e)
{
if (e?.SelectedItem == null) return;
JournalGroupList.SelectedItem = null;
JournalHistoryViewPage journalHistoryViewPage = App.Container.Resolve<JournalHistoryViewPage>();
journalHistoryViewPage.BaseViewModel.JournalGroup = e.SelectedItem as JournalGroup;
journalHistoryViewPage.BaseViewModel.SelectedPatient = BaseViewModel.SelectedPatient;
Navigate(journalHistoryViewPage);
}
private async void VitalSigns_Tapped(object sender, System.EventArgs e)
{
var vitalSignsViewPage = App.Container.Resolve<VitalSignsViewPage>();
vitalSignsViewPage.BaseViewModel.SelectedPatient = BaseViewModel.SelectedPatient;
Navigate(vitalSignsViewPage);
}
public override async void Navigate(Page page)
{
await Navigation.PushAsync(page, true);
}
如果每個(gè)頁面都有一個(gè)BaseViewModel.SelectedPatient和 具有相同的值,你也可以將它組合成 Navigate 函數(shù),例如:
public override async void Navigate(Page page)
{
page.BaseViewModel.SelectedPatient = BaseViewModel.SelectedPatient;
await Navigation.PushAsync(page, true);
}
- 1 回答
- 0 關(guān)注
- 92 瀏覽
添加回答
舉報(bào)