Shell.Current.GoToAsync Failed with Error: java.lang.IllegalStateException: The specified child already has a parent.

Fan Yang 0 Reputation points
2024-06-21T19:32:07.13+00:00

In my ViewModel, I had a RelayCommand to send parameters to another page.

[RelayCommand]
public async Task ReviewIt()
{
 // ...
 await Shell.Current.GoToAsync(nameof(ReviewItView), new Dictionary<string, object>{ ["key1"] = value1, ["key2"] = value2 })
}

but it failed with the exception: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

How to correct this?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,607 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.