public async Task NavigateTo(string screenName, object param = null) { if (_currentScreen?.ScreenName == screenName || _inLoadingScreenName == screenName) { return; } _inLoadingScreenName = screenName; var viewModelType = _mapper.GetViewModelType(screenName); if (viewModelType == null) { _logger.LogError($"no screen view model found for {screenName}"); Relogin(); return; } if (_currentScreen != null) { await _router.HideScreen(); } _scopeManager.OpenScope(screenName); var nextScreen = (ScreenViewModelBase)_scopeManager.Resolve(viewModelType, IfUnresolved.Throw); try { await((IViewModel)nextScreen).InitializeAsync(param); if (_currentScreen != null) { await _currentScreen.OnNavigatingFrom(); _currentScreen.Dispose(); } _currentScreen = nextScreen; await _router.PrepareScreen(nextScreen); _inLoadingScreenName = null; await _currentScreen.OnNavigatedTo(); } catch (Exception e) { _logger.LogError($"NavigationService: {viewModelType.Name} InitializeAsync failed with exception: {e}"); nextScreen.Dispose(); await _router.UnHideScreen(); throw; } }