In Xamari.Forms, I use the following route declaration in AppShell.xaml :
<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"/>
In the AppShell.xaml.cs, I add programatically a contextual page navigation for the Toolbox page:
public AppShell ()
{
InitializeComponent ();
Routing.RegisterRoute("Toolbox/TBOuvriers", typeof(TBOuvriers));
BindingContext = this;
}
When I try to display the contextual page navigation from the Toolbox Page:
- await Shell.Current.GoToAsync("//Main/Toolbox/TBOuvriers");*
I get this Exception :
System.ArgumentException: Ambiguous routes matched for: //Main/Toolbox/TBOuvriers matches found:
//Main/Toolbox/TBOuvriers/TBOuvriers,
//Main/IMPL_Toolbox/Toolbox/TBOuvriers
Parameter name: uri
Just before the call, I can see those values for the Shell variables :
- Shell.Current.CurrentItem : "Title = Toolbox, Route = Main"
Shell.Current.CurrentState.Location : "{//Main/Toolbox}"*
Which seem to be the expected one's.
If I try to display the page with this call:
- await Shell.Current.GoToAsync("TBOuvriers");*
I also get an Exception : System.Exception: Timeout exceeded getting exception details
So, What's the problem ?
Where does those routes come from ?!?
Why is the Toolbox page 2 times registered ?
All ideas are welcome !
Best regards
2条答案
按热度按时间zf2sa74q1#
对于任何人,将面临这个问题,并有这个错误信息太;
System.ArgumentException:'匹配的路由不明确:...'
当您在XAML中注册路由(在appshell文件中),并且还尝试在C#的代码隐藏中注册路由时,会发生这种情况。请仅使用XAML或C#注册路由一次,而不要同时使用两者。
gfttwv5a2#
如果你有2个注册无论什么原因尝试:
然后在代码中
根据您的导航,您可能希望尝试:
或
PS我讨厌AppShell导航