private void textboxSetInputState() { SearchMemberTextBox.Clear(); // Set textbox foreground to theme's regular InputText brush SearchMemberTextBox.Foreground = FindResource("InputText") as SolidColorBrush; SearchMemberTextBox.CaretBrush = SearchMemberTextBox.Foreground; }
public Login() { // Get view model viewModel = Application.Current.Resources["LoginViewModel"] as LoginViewModel; this.DataContext = viewModel; InitializeComponent(); // Save reference to SearchMemberTextBox for scanner functionality Application.Current.Resources["TextBoxDefaultStateCommand"] = new RelayCommand((o) => this.Dispatcher.BeginInvoke(new Action(textboxSetDefaultState))); Application.Current.Resources["SearchMemberTextBox"] = SearchMemberTextBox; Application.Current.Resources["SubitCommand"] = new RelayCommand((o) => submit(o as String)); /*Loaded += delegate * { * // Lock in SearchMemberTextBox width after initialization * double w = SearchMemberTextBox.ActualWidth; * SearchMemberTextBox.Width = w * 1.1; * };*/ // Set member search textbox to default state textboxSetDefaultState(); // Submit if <Enter> key pressed SearchMemberTextBox.InputBindings.Add(new InputBinding(new RelayCommand(o => { string q = SearchMemberTextBox.Text; if (q != "") { if (submit(q) == 1) { SearchMemberTextBox.Clear(); } return; } if (q == "") { LoginViewModel.DoDisplayError = true; LoginViewModel.ErrorMessage = "Must contain text"; LoginViewModel.ErrorDisplayRule = "TextChanged"; } viewModel.ForceValidateCommand.Execute(null); }), new KeyGesture(Key.Enter))); // Declare voice synthesizer speaker = new SpeechSynthesizer(); }