Hi everyone I have a big problem
I'm new using Xamarin and I'm learning while developing my first app. Now, I'm trying to achieve Shell Navegation with pages that are not in the Shell Content (for example, a detail page of an object).
In many tutorials they used the following code:
On the AppShell constructor we define the Routing:
-Routing.RegisterRoute(nameof(MyCoffeeDetailsPage), typeof(MyCoffeeDetailsPage));
MyCoffeeDetailsPage is the Page I want to move on. It's empty, just default settings
Next, on the modelview we create an AsyncCommand to control the navegation:
- public AsyncCommand TravelCommand { get; }
- public CoffeeEquipmentViewModel()
{
TravelCommand = new AsyncCommand(Travel);
}
- async Task Travel ()
{
var route = $"{nameof(MyCoffeeDetailsPage)}";
await Shell.Current.GoToAsync(nameof(MyCoffeeDetailsPage));
}
Now, everything is created, the next step is on the AXML binding this command to the proper button
- <Button Text="Travel" Command="{Binding TravelCommand}"/>
It seems that this should works, but when I press the button the app crashes. Besides, I debug what is going on and the problem is the next one:
- The await sentences on Travel calls the constructor of MyCoffeeDetailsPage. Inside this constructor, it executes the InitializeComponent and when it finish... it comes again to the constructor and the InitializeComponent in an endless loop.
Someone knows what is going on??