private void LoginButton_Click(object sender, RoutedEventArgs e) { //Заасинхронить это дело AccountViewModel AccountVM = new AccountViewModel(); SettingsViewModel SettingsVM = new SettingsViewModel(); AccountVM.SetSession(AccountVM.Authorize(LoginField.Text, PasswordField.Password)); PasswordField.Password = ""; if (globalCurrentAccount == null) { return; } UsernameHolder.Content = globalCurrentAccount.UserName; SettingsVM.ActivateSettingsProfile(SettingsVM.GetSelectedProfile(globalCurrentAccount)); ProfilesList.ItemsSource = SettingsVM.GetProfilesList(); ProfilesList.SelectedIndex = ProfilesList.Items.IndexOf(globalCurrentSettingsProfile); MessageBox.Show(ProfilesList.Items.IndexOf(globalCurrentSettingsProfile).ToString()); //Выбор в зависимости от профиля LoginGrid.Visibility = Visibility.Collapsed; SavedProfiles.Visibility = Visibility.Visible; }