微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从 ContentView 打开 ContentPage?

如何解决如何从 ContentView 打开 ContentPage?

我在 Xamarin.forms.Maps 中有一个 ContentView,我在 ListView 中使用该视图。单击地图时我需要打开一个页面

我尝试如下:

MapClicked="MapClicked"

private async void MapClicked(object sender,MapClickedEventArgs e)
{
    var item = (History)((Map)sender).BindingContext;
    await Navigation.PushModalAsync(new Pages.Page1());
}

当我点击地图时,这些线被触发,但 Page1 没有打开。那么从 ContentPage 打开 ContentView 的确切方法是什么?

参考:Xamarin Forms: How to bind the position value of Xamarin.forms.Maps inside the ListView?

解决方法

您应该将 const app = ReactDOMServer.renderToString(<App />); const helmet = Helmet.renderStatic() const indexFile = path.resolve('./build/index.html'); fs.readFile(indexFile,'utf8',(err,data) => { let updated = data.replace('<div id="root"></div>',`<div id="root">${app}</div>`); return res.send(updateHtmlContent(updated,helmet)); } 作为要导航的根页面。阅读更多信息:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/hierarchical

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。