곤충? System.ArgumentException : '다음에 대한 경로를 알아낼 수 없습니다.
Nov 25 2020
오류
System.ArgumentException : '다음에 대한 경로를 알아낼 수 없습니다 : // RegisterPage 매개 변수 이름 : uri'System.ArgumentException : '다음에 대한 경로를 알아낼 수 없습니다 : // LogoPage 매개 변수 이름 : uri'
뭐가 잘못 되었 니? 경로를 알 수 없습니다 ...?
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MyApp.Views.WelcomePage"
Shell.NavBarIsVisible="False">
<ContentPage.Content>
<StackLayout Padding="10,0,10,0" VerticalOptions="Center">
<Button VerticalOptions="Center" Text="Register" Command="{Binding RegisterCommand}"/>
<Button VerticalOptions="Center" Text="Login" Command="{Binding LoginCommand}"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
뒤에 코드
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class WelcomePage : ContentPage
{
public WelcomePage()
{
InitializeComponent();
this.BindingContext = new WelcomeViewModel();
}
}
WelcomeViewModel.cs
public Command RegisterCommand { get; }
public Command LoginCommand { get; }
public WelcomeViewModel()
{
RegisterCommand = new Command(OnRegisterClicked);
LoginCommand = new Command(OnLoginClicked);
}
private async void OnRegisterClicked(object obj)
{
await Shell.Current.GoToAsync($"//{nameof(RegisterPage)}"); } private async void OnLoginClicked(object obj) { await Shell.Current.GoToAsync($"//{nameof(LoginPage)}");
}
답변
3 Cfun Nov 25 2020 at 10:40
를 사용하여 탐색하려는 각 페이지에 대한 경로를 등록해야합니다. Shell.Current.GoToAsync()
이렇게하면 페이지 계층 구조를 명확히 할 수도 있습니다.
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="RegisterPage"
Route="RegisterPage"
ContentTemplate="{DataTemplate local:RegisterPage}"/>
<ShellContent Title="LoginPage"
Route="LoginPage"
ContentTemplate="{DataTemplate local:LoginPage}"/>
<ShellContent Title="Page3"
ContentTemplate="{DataTemplate local:Page3}"/>
</FlyoutItem>
Routing.RegisterRoute()
경로가 호출되기 전에 실행되는 한 원하는 경우 코드에서를 사용하여 경로를 등록 할 수도 있습니다 .Routing.RegisterRoute("//Page3", typeof(Page3));
Microsoft 문서
자세한 내용 : 셸 탐색