0
votes

Hi guys I have a very weird issue in MVVMCross right now.

I'm trying to close a page by using navigationService.Close(this), but it doesn't close. In the logging I'm seeing the following message: Ignoring close for ViewModel - Matching View for ViewModel instance failed.

I checked on Github where this message is thrown and it is exactly what it says it can't find the view which needs to be closed. But now the weird thing: If I just change the presentation to Modal (which I don't want in this case) the close command just works.

Is this a bug? Am I doing something wrong? Can anyone help me?

Maybe it is because we have a TabbedRootViewModel in which the navigation is done?

1
Could you please add the code where the issue occurs? - Nikhileshwar
I just call navigationService.Close(this) in the ViewModel. What other code would help to see? - CliffConclusion
I use navigationservice.Close(this) it works. I use it in a MvxContentPage what View do you use it in? Can you try navigationService.Navigate(previousViewModel) - Nikhileshwar
I also have an MvxContentPage, but the navigation happens in a MvxTabbedPagePresentation. So that maybe could be the cause. I tried navigationService.Navigate(previousViewModel) and that just works, but then of course it navigates as a next page which is not what I want. - CliffConclusion
For anyone else landing here with this issue, for me I had used a back stack hint handler to clear the stack inside ViewAppeared, resulting in the call to avigationService.Close(this) failing. No error was reported to the console for me though. - Leigh

1 Answers

0
votes

Fixed it (somehow) by setting WrapInNavigationPage = true in the TabbedRootViewModel. This did give some other issues like a double navigationBar. Which I fixed by turning off the navigationBar in XAML. So it's not the ideal solution, but it is a solution :)