private async void GameNameTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { HideIntellisense(); if (shouldShowIntellisense) { if (!string.IsNullOrEmpty(this.GameNameTextBox.Text)) { var games = (await ChannelSession.Connection.GetGameTypes(this.GameNameTextBox.Text, 5)) .Take(5) .ToList(); if (games.Count > 0) { GameNameIntellisenseListBox.ItemsSource = games; // Select the first game GameNameIntellisenseListBox.SelectedIndex = 0; Rect positionOfCarat = this.GameNameTextBox.GetRectFromCharacterIndex(this.GameNameTextBox.CaretIndex, true); if (!positionOfCarat.IsEmpty) { Point topLeftOffset = this.GameNameTextBox.TransformToAncestor(MainGrid).Transform(new Point(positionOfCarat.Left, positionOfCarat.Top)); ShowIntellisense(topLeftOffset.X, topLeftOffset.Y); } } } } }
/// <summary> /// 數字遮罩 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void te_TextChanged(object sender, Controls.TextChangedEventArgs e) { if (!IsFirstTime) { var te = (sender as Controls.TextBox); int index = (te.Name == "teStart" ? 0 : 1); if (te.Text == "" || te.Text == null) { te.Text = "0"; } else { int i = 0; if (!int.TryParse(te.Text, out i)) { te.Text = OldText[index].ToString(); } else { te.Text = i.ToString(); OldText[index] = i; } } } }
private void search_TextChanged(object sender, TextChangedEventArgs e) { //damit search auf "" gesetzt werden kann if (skipTextChange) { return; } else { clearTextBoxes(); string text = search.Text; List<string> autoList = new List<string>(); //case no sensitive --> ToUpper, 1 ... vorname,leer taste , 2 ... nachname List<Kunde> kunden = hm.repKunde.Get().Where(k => (k.vornameKunde + " " + k.nachnameKunde).ToUpper().StartsWith(text.ToUpper())).ToList(); if (kunden.Count() > 0) { lbSuggestion.ItemsSource = kunden; lbSuggestion.Visibility = Visibility.Visible; } else { lbSuggestion.Visibility = Visibility.Hidden; lbSuggestion.ItemsSource = null; } //wenn textbox leer ist if (string.IsNullOrEmpty(search.Text)) { lbSuggestion.Visibility = Visibility.Hidden; lbSuggestion.ItemsSource = null; } } }
private void textBox_TextChanged(object sender, TextChangedEventArgs e) { if (textBox.Text.Length > 0 && textBox.Text != "Run...") button.IsEnabled = true; else if(button != null) button.IsEnabled = false; }
private void VotingsFilter_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { List <Voting> NewList = new List <Voting>(); if (!string.IsNullOrEmpty(TextFilter.Text)) { foreach (Voting vote in AllVotings) { if (vote.VoteName.Contains(TextFilter.Text)) { NewList.Add(vote); } } FilteredVotings = NewList; VotingsList.ItemsSource = null; VotingsList.ItemsSource = NewList; VotingsList.SelectedIndex = 0; } else { FilteredVotings = AllVotings; VotingsList.ItemsSource = null; VotingsList.ItemsSource = AllVotings; VotingsList.SelectedIndex = 0; } }
private void TextBoxManual_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (TextBoxManual.CaretIndex == 0) { TextBoxManual.CaretIndex = TextBoxManual.Text.Length; } }
private void SearchField_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { // TODO: Add event handler implementation here. App MyApplication = ((App)Application.Current); MyApplication.Search(SearchField.Text); }
private void ZPasswordBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (!this.mIsHandledTextChanged) { return; } if (!string.IsNullOrEmpty(this.Password)) { foreach (TextChange c in e.Changes) { //从密码文中根据本次Change对象的索引和长度删除对应个数的字符 this.Password = this.Password.Remove(c.Offset, c.RemovedLength); //将Text新增的部分记录给密码文 this.Password = this.Password.Insert(c.Offset, Text.Substring(c.Offset, c.AddedLength)); } } int textLength = string.IsNullOrEmpty(this.Text)?0:this.Text.Length; if (!this.ShowPassword) { this.SetText(ConvertToPasswordChar(textLength)); } //将光标放到最后面 this.SelectionStart = textLength + 1; }
private void UsersFilter_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { List <User> NewList = new List <User>(); if (!string.IsNullOrEmpty(UsersFilter.Text)) { foreach (User user in AllUsers) { if (user.Name.Contains(UsersFilter.Text)) { NewList.Add(user); } } FilteredUsers = NewList; UsersList.ItemsSource = null; UsersList.ItemsSource = NewList; UsersList.SelectedIndex = 0; } else { FilteredUsers = AllUsers; UsersList.ItemsSource = null; UsersList.ItemsSource = AllUsers; UsersList.SelectedIndex = 0; } }
private void realTimeInput_TextChanged(object sender, TextChangedEventArgs e) { var inputBox = sender as TextBox; if (inputBox != null) { RealTimeUpdate = inputBox.Text; } }
public void ChangeEdgeWeight(object sender, System.Windows.Controls.TextChangedEventArgs e) { TextBox txt = new System.Windows.Controls.TextBox(); txt = (TextBox)sender; foreach (var edge in EdgesList) { if (edge.textBox == txt) { if (txt.Text == "-" || txt.Text == "") { return; } else if (IsWeightTrue(txt.Text)) { edge.WeightEdge = Convert.ToDouble(txt.Text); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Ввод только цифр! Скидываюсь на 1", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Exclamation); edge.WeightEdge = 1; txt.Text = "1"; } } } }
private void txtSecondaryWeapAmmo_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { /*if (txtSecondaryWeapAmmo.Text == "") { } * else * { * try * { * int validate = int.Parse(txtSecondaryWeapAmmo.Text); * * if (validate > 32767) * { * txtSecondaryWeapAmmo.Text = "32767"; * } * * } * catch * { * int line = txtSecondaryWeapAmmo.Text.Length - 1; * txtSecondaryWeapAmmo.Text = txtSecondaryWeapAmmo.Text.Remove(line, 1); * txtSecondaryWeapAmmo.Select(line, 0); * } * } * * if (txtSecondaryWeapAmmo.Text == "") { txtSecondaryWeapAmmo.Text = "0"; }*/ }
private void Txt_Amt_Sold_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (Txt_Amt_Sold.Text != "") { Checkinput(int.Parse(Txt_Amt_Sold.Text)); } }
private void TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (this.IsInitialized) { UpdateView(); } }
private void ShowSuggestions7(object sender, System.Windows.Controls.TextChangedEventArgs e) { dbman = new DBConnectionManager(); MinisterSuggestionArea.Items.Clear(); if (dbman.DBConnect().State == ConnectionState.Open) { MySqlCommand cmd = dbman.DBConnect().CreateCommand(); cmd.CommandText = "SELECT DISTINCT minister FROM matrimonial_records WHERE " + "minister LIKE @query;"; cmd.Parameters.AddWithValue("@query", "%" + Minister.Text + "%"); cmd.Prepare(); MySqlDataReader db_reader = cmd.ExecuteReader(); while (db_reader.Read()) { MinisterSuggestionArea.Items.Add(db_reader.GetString("minister")); } //close Connection dbman.DBClose(); Suggestions7.Visibility = System.Windows.Visibility.Visible; } else { } }
private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (!string.IsNullOrEmpty(this.AmountTextBox.Text) && int.TryParse(this.AmountTextBox.Text, out int amount) && amount > 0) { this.currencyData.Amount = amount; } }
private void txtCount_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { //屏蔽中文输入和非法字符粘贴输入 TextBox textBox = sender as TextBox; NoChange(textBox, e, t => { int i = 0; return(Int32.TryParse(t, out i)); }); }
private void ShowSuggestions1(object sender, System.Windows.Controls.TextChangedEventArgs e) { dbman = new DBConnectionManager(); PlaceOfBaptismSuggestionArea.Items.Clear(); if (dbman.DBConnect().State == ConnectionState.Open) { MySqlCommand cmd = dbman.DBConnect().CreateCommand(); cmd.CommandText = "SELECT DISTINCT place_of_baptism FROM confirmation_records WHERE " + "place_of_baptism LIKE @query;"; cmd.Parameters.AddWithValue("@query", "%" + PlaceOfBaptism.Text + "%"); cmd.Prepare(); MySqlDataReader db_reader = cmd.ExecuteReader(); while (db_reader.Read()) { PlaceOfBaptismSuggestionArea.Items.Add(db_reader.GetString("place_of_baptism")); } //close Connection dbman.DBClose(); Suggestions1.Visibility = System.Windows.Visibility.Visible; } else { } }
private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { curQuickFltrStr = tboxQfltr.Text.ToLower(); InitSelectorCombo(true); //SaveComboTagParing("TextBox_TextChanged"); SetPrefFltrsFromQFltrTboxPerMode(); }
private void txtWebsite_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (allFieldsPopulated()) { frmButton.IsEnabled = true; } }
private void txtBarcodeImageFile_TextChanged(object sender, TextChangedEventArgs e) { if (File.Exists(txtBarcodeImageFile.Text)) { imageBarcode.Source = new BitmapImage(new Uri(txtBarcodeImageFile.Text)); } }
private void Textbox_TextChanged(object sender, TextChangedEventArgs e) { _currentDeck.Note = Textbox.Text; _currentDeck.Edited(); _noteChanged = true; BtnSave.IsEnabled = true; }
private void inputTb_TextChanged(object sender, TextChangedEventArgs e) { string text = inputTb.Text; chars.Clear(); charFrequencies.Clear(); for (int i = 0; i < text.Length; i++) { var symbol = Char.ToLower(text[i]); if (Char.IsLetter(symbol)) { int count = 0; charFrequencies.TryGetValue(symbol, out count); count++; charFrequencies[symbol] = count; if (!chars.Contains(symbol)) { chars.Add(symbol); } } } chars = new ObservableCollection<char>(chars.OrderBy(c => c)); UpdateHorizontalAxis(); DataContext = null; DataContext = charFrequencies; }
private void searchTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (searchTextBox.Text == "") { AppComponent.StopThreads(); ImageBrush textImageBrush = new ImageBrush(); try { textImageBrush.ImageSource = new BitmapImage( new Uri("res/searchBackground.png", UriKind.Relative) ); } catch { } textImageBrush.AlignmentX = AlignmentX.Left; textImageBrush.Stretch = Stretch.None; searchTextBox.Background = textImageBrush; PublishWords(FileData.FileContents); } else { SolidColorBrush b = new SolidColorBrush(); b.Color = Color.FromRgb(255, 255, 255); searchTextBox.Background = b; RunSearch(searchTextBox.Text); } }
private void firstTb_TextChanged(object sender, TextChangedEventArgs e) { tbValue2.Text = tbValue1.Text; tbValue3.Text = tbValue1.Text; tbValue4.Text = tbValue1.Text; checkValid(); }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { double temp; if (Button_OK != null && VoltageValue != null) { Button_OK.IsEnabled = double.TryParse(VoltageValue.Text, out temp); } }
private void checkValid(object sender, TextChangedEventArgs e) { bool isValid = true; if (tbMeaDryTBefore.Text == null || tbMeaDryTBefore.Text == "" || tbMeaWetTBefore.Text == null || tbMeaWetTBefore.Text == "" || tbMeaPressBefore.Text == null || tbMeaPressBefore.Text == "") { isValid = false; lbMsg.Visibility = Visibility.Visible; lbMsg.Content = "数据未输入完全!"; } else { try { Convert.ToDouble(tbMeaDryTBefore.Text); Convert.ToDouble(tbMeaWetTBefore.Text); Convert.ToDouble(tbMeaPressBefore.Text); lbMsg.Visibility = Visibility.Hidden; } catch { isValid = false; lbMsg.Visibility = Visibility.Visible; lbMsg.Content = "请输入正确的数字!"; } } if (!isValid) { btNext.IsEnabled = false; } else { btNext.IsEnabled = true; } }
private void OnTextChanged(object sender, TextChangedEventArgs e) { if (_textChangedTimer.Enabled) _textChangedTimer.Stop(); _textChangedTimer.Start(); }
private void CompanyNameField_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (InstaSearchCheckBox.IsChecked == true) { searchMethod(); } }
private void emailTxt_TextChanged(object sender, TextChangedEventArgs e) { if(emailTxt.Text.Contains("@")) button1.IsEnabled = true; else button1.IsEnabled = false; }
private void txtNombrePromotor_TextChanged(object sender, TextChangedEventArgs e) { Promotore _promotor = new Promotore(); _promotor.Nombre = txtNombrePromotor.Text; dgPromotor.ItemsSource = _promotorBL.ObtenerPromotoresPorNombre(_promotor); }
private static void TextBox_TextChanged(object sender, TextChangedEventArgs e) { TextBox textBox = e.Source as TextBox; if (textBox != null) { RememberHasText(textBox); } }
protected override void OnTextChanged(TextChangedEventArgs e) { if (string.IsNullOrEmpty(Text) && !IsFocused) SetLabel(); base.OnTextChanged(e); }
private void txtPlasmaNadeCount_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { /*if (txtPlasmaNadeCount.Text == "") { } * else * { * try * { * int validate = int.Parse(txtPlasmaNadeCount.Text); * * if (validate > 127) * { * txtPlasmaNadeCount.Text = "127"; * } * * } * catch * { * int line = txtPlasmaNadeCount.Text.Length - 1; * txtPlasmaNadeCount.Text = txtPlasmaNadeCount.Text.Remove(line, 1); * txtPlasmaNadeCount.Select(line, 0); * } * } * * if (txtPlasmaNadeCount.Text == "") { txtPlasmaNadeCount.Text = "0"; }*/ }
private void txtName_TextChanged(object sender, TextChangedEventArgs e) { if (txtName.Text != "") btnSave.IsEnabled = true; else btnSave.IsEnabled = false; }
private void textBox_Copy_TextChanged(object sender, TextChangedEventArgs e) { int val = 0; int.TryParse(textBox_Copy.Text, out val); Properties.Settings.Default.endIndex = val; Properties.Settings.Default.Save(); }
private void State_Changed(object sender, TextChangedEventArgs e) { if (((TextBox) sender).Text.Equals("Sucess")) { SwitchToMainMenu(); } }
private void txtPromProy_TextChanged(object sender, TextChangedEventArgs e) { PromotorProyecto _promproy = new PromotorProyecto(); _promproy.Promotore = _promB; dgPromotorProy.ItemsSource = _prompBL.ObtenerPromotoresProyectoPorNombre(_promproy); }
private void tbIPAddress_TextChanged(object sender, TextChangedEventArgs e) { if (checkValidIPAddress(tbIPAddress.Text)) { btnOkay.IsEnabled = true; } }
private void txtNombreADESCO_TextChanged(object sender, TextChangedEventArgs e) { ADESCO _adesco = new ADESCO(); _adesco.Nombre = txtNombreADESCO.Text; dgADESCO.ItemsSource = _adescoBL.ObtenerADESCOSPorNombre(_adesco); }
private void txtNombreMiembros_TextChanged(object sender, TextChangedEventArgs e) { MiembrosADESCO _miembro = new MiembrosADESCO(); _miembro.Nombre = txtNombreMiembros.Text; dgMiembros.ItemsSource = _miembrosADESCOSBL.ObtenerMiembrosADESCOSPorNombre(_miembro); }
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)//Parsing, and Creating Auotcomplete list based on user input; { (sender as TextBox).ContextMenu.IsEnabled = true; (sender as TextBox).ContextMenu.PlacementTarget = (sender as TextBox); (sender as TextBox).ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; List<MenuItem> autoCompleteItems = new List<MenuItem>(); if ((sender as TextBox).Text != "") { foreach (Instructor instructor in instructors) { if (CompareForAutoComplete((sender as TextBox).Text, instructor)) {//Parsing input to check if it matches name or lastname of any item in the list MenuItem item = new MenuItem(); item.Header = instructor.ToString(); item.Tag = instructor; item.Click += item_Click; autoCompleteItems.Add(item); } Autocomplete.Items.Clear(); foreach (MenuItem item in autoCompleteItems) { Autocomplete.Items.Add(item); } } Autocomplete.StaysOpen = true; (sender as TextBox).ContextMenu.IsOpen = true; } }
/// <summary> /// TextChanged event handler for secure storing of password into Visual Tree, /// text is replaced with pwdChar chars, clean text is kept in /// Text property (CLR property not snoopable without mod) /// </summary> protected override void OnTextChanged(TextChangedEventArgs e) { if (dirtyBaseText) return; string currentText = BaseText; int selStart = SelectionStart; if (password != null && currentText.Length < password.Length) { // Remove deleted chars password = password.Remove(selStart, password.Length - currentText.Length); } if (!string.IsNullOrEmpty(currentText)) { for (int i = 0; i < currentText.Length; i++) { if (currentText[i] != pwdChar) { Debug.Assert(password != null, "Password can't be null here"); // Replace or insert char string currentCharacter = currentText[i].ToString(CultureInfo.InvariantCulture); password = BaseText.Length == password.Length ? password.Remove(i, 1).Insert(i, currentCharacter) : password.Insert(i, currentCharacter); } } Debug.Assert(password != null, "Password can't be null here"); BaseText = new string(pwdChar, password.Length); SelectionStart = selStart; } base.OnTextChanged(e); }
private void OnTextBoxTextChanged(object sender, TextChangedEventArgs e) { TextBox textBox = sender as TextBox; // Update the binding source BindingExpression bindingExpr = textBox.GetBindingExpression(TextBox.TextProperty); bindingExpr.UpdateSource(); }
private void TextBoxLink_TextChanged(object sender, TextChangedEventArgs e) { if (!radioCustomURL.IsChecked.HasValue || !radioSteamID.IsChecked.HasValue) //IsChecked is a Nullable<bool>. We can't continue if either are null. { return; } //TODO: CHANGE THIS METHOD if((bool)radioCustomURL.IsChecked) { if(tbLink.Text.Length < "steamcommunity.com/id/".Length) { tbLink.Text = "steamcommunity.com/id/"; tbLink.SelectionStart = tbLink.Text.Length + 1; } } else if((bool)radioSteamID.IsChecked) { if(tbLink.Text.Length < "steamcommunity.com/profiles/".Length) { tbLink.Text = "steamcommunity.com/profiles/"; tbLink.SelectionStart = tbLink.Text.Length + 1; } } }
private void priceChanged(object sender, TextChangedEventArgs e) { TextBox current = sender as TextBox; decimal price = 0, vat = 0, priceVat = 0; this.price.TextChanged -= priceChanged; this.priceVat.TextChanged -= priceChanged; if ((current.Name == "vat" && this._loaded.Name == "priceVat") || current.Name == "priceVat") { this._loaded = this.priceVat; if (decimal.TryParse(this.priceVat.Text.ToString(), out priceVat) && decimal.TryParse(this.vat.Text.ToString(), out vat)) { this.price.Text = Math.Round((priceVat / (1 + vat / 100)), 3).ToString("F"); this.priceVat.Text = priceVat.ToString("F"); } } else { this._loaded = this.price; if (decimal.TryParse(this.price.Text.ToString(), out price) && decimal.TryParse(this.vat.Text.ToString(), out vat)) { this.priceVat.Text = Math.Round((price * (1 + vat / 100)), 3).ToString("F"); this.price.Text = price.ToString("F"); } } this.price.TextChanged += priceChanged; this.priceVat.TextChanged += priceChanged; }
private void textBoxSideB_TextChanged(object sender, TextChangedEventArgs e) { long content; try { content = Convert.ToInt64(textBoxSideB.Text); if (content > 0) { b = content; if (a != null && c != null) { Calculate(); } else { labelResult.Content = string.Empty; } } else { b = null; labelResult.Content = "The sides must be positive!"; image.Source = null; } } catch (FormatException) { b = null; labelResult.Content = "The sides must be a positive integer"; image.Source = null; } }
private void textBox1_TextChanged(object sender, TextChangedEventArgs e) { foreach (TextChange tc in e.Changes) { if (tc.AddedLength > 0) { if (_iowBS.typedChars.Length <= _iowBS.numberOfTypedChars) return; textBox1.BorderBrush = Brushes.Black; for (int i = 0; i < tc.AddedLength; i++) { char c = textBox1.Text[tc.Offset + i]; if (c == '\\') inHex = true; else if (inHex) { if (charCount == 0) lastChar[charCount++] = c; else { lastChar[1] = c; string s = new string(lastChar); _iowBS.inByte = Convert.ToByte(s, 16); inHex = false; charCount = 0; } } else { _iowBS.inByte = (byte)c; } } } } }
private void textBoxSearch_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (lvFiles.ItemsSource != null) { CollectionViewSource.GetDefaultView(lvFiles.ItemsSource).Refresh(); } }
private void txtSearch_TextChanged(object sender, TextChangedEventArgs e) { if (txtSearch.Text != "") { int id = Int32.Parse(txtSearch.Text); Student student = rep.getStudent(id); txtName.Text = student.StudentName; if (student.StudentAddress != null) { txtDireccion1.Text = student.StudentAddress.Address1; txtDireccion2.Text = student.StudentAddress.Address2; txtCiudad.Text = student.StudentAddress.City; } else { txtDireccion1.Text = ""; txtDireccion2.Text = ""; txtCiudad.Text = ""; } txtStandardId.Text = student.StudentID.ToString(); dataGrid.ItemsSource = student.Course.ToList(); } }
private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { var svc = ServiceFactory.GetService(); var text = (sender as TextBox).Text; result.Text = svc.GetWords(text).Aggregate("", (x, y) => x + "\n" + y); }
// User-control interaction events private void Tbx_numTrees_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (btn_rebuild == null) { return; } btn_rebuild.IsEnabled = true; }
private void updatePanAnimation(object sender, System.Windows.Controls.TextChangedEventArgs e) { var tb = sender as TextBox; int time = int.Parse(tb.Text); TimeSpan interval = new TimeSpan(0, 0, time); MyMap.PanDuration = interval; }
void OnTextChanged(object sender, SWC.TextChangedEventArgs routedEventArgs) { var view = (ITextCellViewFrontend)CellView; Load(sender as FrameworkElement); SetCurrentEventRow(); routedEventArgs.Handled = view.RaiseTextChanged(); }
private async void GameNameComboBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (!string.IsNullOrWhiteSpace(this.GameNameComboBox.Text) && this.GameNameComboBox.SelectedIndex < 0) { this.relatedGames.Clear(); await this.GetRelatedGamesByName(this.GameNameComboBox.Text); } }
private void txtNum_OnTextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (CheckBoxSureAdd.Visibility == Visibility.Hidden) { CheckBoxSureAdd.Visibility = Visibility.Visible; CheckBoxSureAdd.IsChecked = false; } }
private void txtAccount_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (txtAccount.Text.ToLower() == "imdm") { IsDebug = true; CheckDebug(); } }
private void AutoCompleteBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { //如果是因为选择了联想列表项导致文本框文本被改变则不进行再次联想 if (this.mIsEnterKeyDown) { this.mIsEnterKeyDown = false; return; } //文本框没有文本时关闭联想列表 if (string.IsNullOrWhiteSpace(this.Text)) { this.IsDropDownOpen = false; return; } if (collectionView == null) { collectionView = CollectionViewSource.GetDefaultView(this.ItemsSource); } Task.Factory.StartNew(() => { this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { collectionView.Filter = (o) => { if (string.IsNullOrEmpty(this.DisplayMemberPath) && (this.FilterMemberSource.Count == 0 || this.FilterMemberSource == null)) { return(Convert.ToString(o).Contains(this.Text)); } else { //foreach (PropertyFilterDescription item in this.FilterMemberSource) //{ //} object value = Utils.CommonUtil.GetPropertyValue(o, this.DisplayMemberPath); System.Diagnostics.Debug.WriteLine(Convert.ToString(value)); return(Convert.ToString(value).Contains(this.Text)); } }; })); }); int count = ((System.Windows.Data.ListCollectionView)collectionView).Count; if (count > 0) { this.SelectedIndex = 0;//默认选中第一个联想项 this.IsDropDownOpen = true; } else { this.IsDropDownOpen = false; } }
private void TextBox_TabNext_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (((TextBox)sender).MaxLength == ((TextBox)sender).Text.Length) { var ue = e.OriginalSource as FrameworkElement; e.Handled = true; ue.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); } }
private void ApplyFiltering(object sender, System.Windows.Controls.TextChangedEventArgs e) { if (this.Objects == null) { return; } this.ObjectsList.ItemsSource = this.Objects.Where(x => x.Contains(this.FilterTextBox.Text)).ToList(); }