Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms Xamarin Shell引发不明确路由匹配异常_Forms_Shell_Xamarin_Routes - Fatal编程技术网

Forms Xamarin Shell引发不明确路由匹配异常

Forms Xamarin Shell引发不明确路由匹配异常,forms,shell,xamarin,routes,Forms,Shell,Xamarin,Routes,在Xamari.Forms中,我在AppShell.xaml中使用以下路由声明: 当我尝试从工具箱页面显示上下文页面导航时: wait Shell.Current.GoToAsync(“//Main/Toolbox/TBOuvriers”) 我得到这个例外: System.ArgumentException:找到的匹配项: //主/工具箱/TBOuvriers/TBOuvriers, //主/执行工具箱/工具箱/TBOuvriers 参数名称:uri 在调用之前,我可以看到Shell变量的值:

在Xamari.Forms中,我在AppShell.xaml中使用以下路由声明:

当我尝试从工具箱页面显示上下文页面导航时:
wait Shell.Current.GoToAsync(“//Main/Toolbox/TBOuvriers”)

我得到这个例外:

System.ArgumentException:找到的匹配项:
//主/工具箱/TBOuvriers/TBOuvriers,
//主/执行工具箱/工具箱/TBOuvriers
参数名称:uri

在调用之前,我可以看到Shell变量的值:
Shell.Current.CurrentItem:“Title=Toolbox,Route=Main”
Shell.Current.CurrentState.Location:“{//Main/Toolbox}”

这似乎是人们所期待的。

如果我尝试显示包含此调用的页面:
等待Shell.Current.GoToAsync(“TBOuvriers”)
我还得到一个异常:System.Exception:获取异常详细信息时超时

那么,有什么问题吗?
那些路线是从哪里来的
为什么工具箱页面注册了2次?

欢迎提出任何意见


向将面临此问题的所有人致以最诚挚的问候,同时也向您发送此错误消息

System.ArgumentException:'匹配的不明确路由:…'

当您在XAML(appshell文件)中注册路由,并尝试在C#中的代码隐藏中注册路由时,就会发生这种情况。
只能使用XAML或C(不能同时使用两者)注册一次您的路线。

进一步查看web上的文章,我发现人们主要将新页面(如上下文页面)声明为全局页面,而这些页面不显示在fyout菜单中。如果我这样做,它对我是有效的。在xamarin shell文档中将它们声明为现有页面的子页面(如在我的主题中)有问题吗?同样的观察结果:在Xanimals演示项目中,它们执行
“Routing.RegisterRote”(“monkeydetails”,typeof(MonkeyDetailPage));”
而不是
“Routing.RegisterRote”(“monkey/details”,typeof(MonkeyDetailPage));”
为什么?从每个动物页面调用“wait Shell.Current.GoToAsync(“细节”);”应该比调用“wait Shell.Current.GoToAsync($”{state.Location}/{destinationRoute}?name={animalName}”);更容易,你可以在你的项目中尝试这种方法,这里有什么问题吗?我做的和XAnimals一样。我的所有独立页面都在根目录中注册。但我无法成功地应用他们在官方文件中提出的方法。所以,对我来说很有用,但可能不是最好的方法。如果你有更好的方法来解决这个问题,请在这里分享,谢谢。
 <FlyoutItem Title = "Toolbox"
             FlyoutDisplayOptions="AsMultipleItems"
             Route="Main">

      <ShellContent Title = "Toolbox"
                    ContentTemplate="{DataTemplate Views:Toolbox}"
                    Route="Toolbox"/>

 </FlyoutItem>

 <ShellContent Title = "Parameters"
               ContentTemplate="{DataTemplate Views:Parameters}"
               Route="Parameters"/>
public AppShell ()
{
    InitializeComponent ();

    Routing.RegisterRoute("Toolbox/TBOuvriers", typeof(TBOuvriers));

    BindingContext = this;
}