/// <summary> /// Loads the state. /// </summary> /// <param name="args">The view model arguments.</param> public async Task LoadState(UploadViewModelArgs args) { await base.LoadState(); _editingMode = EditingMode.New; Category = args.Category?.ToCategory(); try { // The user needs to be signed-in await _authEnforcementHandler.CheckUserAuthentication(); // When navigating directly from the main window, the user has not // selected a category yet, so we need to do this now. if (Category == null) { Category = await _navigationFacade.ShowCategoryChooserDialog(); } // Here is some synchronization issue going on, // when we first set the Photo which propagates to the UI // via data binding, and immediately open a ContentDialog via ShowCategoryChooserDialog. // We would get random component initialization exceptions from XAML // without any further details. This however is only noticeable when // the app is launched as share target. // As a solution, we assign the selected photo after the chooser dialog // has been awaited. WriteableBitmap = args.Image; } catch (SignInRequiredException) { await _dialogService.ShowNotification("AuthenticationRequired_Message", "AuthenticationRequired_Title"); _navigationFacade.GoBack(); } }