【问题标题】:How to open a ContentPage from a ContentView?如何从 ContentView 打开 ContentPage?
【发布时间】:2021-01-11 18:17:31
【问题描述】:

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

我尝试如下:

MapClicked="MapClicked"

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

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

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

【问题讨论】:

  • 嗨,我创建了一个 baisc 演示来测试 ListView 中的 mapView。单击地图时导航工作正常。你是如何定义listView的?请发布有关xaml的相关代码,这将有助于重现问题以找出原因。
  • @JarvanZhang-MSFT 对于地图,我使用的是内容视图。导航是在内容视图上实现的。 stackoverflow.com/questions/65390620/…

标签: xamarin.forms contentview


【解决方案1】:

您应该将NavigationPage 作为根页面进行导航。阅读更多:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/hierarchical

【讨论】:

    猜你喜欢
    • 2016-10-18
    • 2017-03-04
    • 2023-02-14
    • 1970-01-01
    • 2020-11-28
    • 2016-12-07
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多