private void SetViewModel(SettingsWindowViewModel viewModel) { CurrentUserRadioButton.IsChecked = viewModel.UserType == SettingsWindowUserType.WindowsUser && viewModel.Username == null; FollowingUserRadioButton.IsChecked = viewModel.UserType == SettingsWindowUserType.WindowsUser && viewModel.Username != null; FollowingManicTimeUserRadioButton.IsChecked = viewModel.UserType == SettingsWindowUserType.ManicTimeUser; UsernameTextBox.Text = viewModel.UserType == SettingsWindowUserType.WindowsUser ? viewModel.Username : ""; PasswordTextBox.Password = viewModel.UserType == SettingsWindowUserType.WindowsUser ? viewModel.Password : ""; DomainTextBox.Text = viewModel.UserType == SettingsWindowUserType.WindowsUser ? viewModel.Domain : ""; ManicTimeUsernameTextBox.Text = viewModel.UserType == SettingsWindowUserType.ManicTimeUser ? viewModel.Username : ""; ManicTimePasswordTextBox.Password = viewModel.UserType == SettingsWindowUserType.ManicTimeUser ? viewModel.Password : ""; }
private void SettingsButton_OnClick(object sender, RoutedEventArgs e) { var settingsViewModel = SettingsWindow.Show(this, _settingsWindowViewModel); if (settingsViewModel != null) { AccessTokenTextBox.Text = string.Empty; _settingsWindowViewModel = settingsViewModel; EnableControls(); } }
public static SettingsWindowViewModel Show(Window owner, SettingsWindowViewModel viewModel) { var window = new SettingsWindow { Owner = owner, WindowStartupLocation = WindowStartupLocation.CenterOwner, ResizeMode = ResizeMode.NoResize, SizeToContent = SizeToContent.WidthAndHeight }; window.SetViewModel(viewModel); return(window.ShowDialog() == true?window.GetViewModel() : null); }