I have a Xamarin forms project, and there is a piece of code where I want to navigate to another page. The error still shows up even though I put that piece of code inside a try-catch. Heres that code:
await Navigation.PushAsync(new QuestionPage(int.Parse(FromLection.SelectedItem.ToString()),
int.Parse(ToLection.SelectedItem.ToString()), questionTypeAsInt));
there's nothing that can be zero, because the FromLection and ToLection are pickers and I check before that none of them are empty. What could cause that error? (EDIT) Here is an image: I can translate if needed
We found the solution: at the transition to a new Page the elements on the first page unload, causing the "selectedIndex" of pickers to be -1 (Nothing selected) Solution: create a variable and save the values of the pickers in it and then give these to the constructor of the new page. credits to @lidqy