protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { TextView = e.NameScope.Find <TextView>("textView"); LogicalChildren.Add(TextView); disposables.Add(TextDocumentProperty.Changed.Subscribe(args => { if (args.NewValue != null) { // Todo unsubscribe these events. TextDocument.Changing += (sender, ee) => { TextDocument?.UndoStack.PushOptional(new RestoreCaretAndSelectionUndoAction(this)); if (BeforeTextChangedCommand != null) { BeforeTextChangedCommand.Execute(null); } }; TextDocument.Changed += (sender, ee) => { InvalidateVisual(); LineHeight = TextView.CharSize.Height; if (TextChangedCommand != null && TextChangedCommand.CanExecute(null)) { TextChangedCommand.Execute(null); } }; } })); }
private void TextChangedDelayTimer_Tick(object sender, EventArgs e) { textChangedDelayTimer.Stop(); if (TextChangedCommand != null && TextChangedCommand.CanExecute(null)) { TextChangedCommand.Execute(null); } }
public async void SearchBar_TextChanged(object sender, TextChangedEventArgs e) { if (HasFilterIcon) { var sbar = sender as Xamarin.Forms.SearchBar; if (string.IsNullOrWhiteSpace(sbar?.Text)) { iconFilter.TranslateTo(0, 0); } else { int transX = -25; //Good for Android if (Device.RuntimePlatform == Device.iOS) { transX = -80; //Good for iOS } if (iconFilter.TranslationX != transX) { iconFilter.TranslateTo(transX, 0, 100); } } } if (TextChangedCommand != null) { if (cts != null) { cts.Cancel(); } cts = new CancellationTokenSource(); var ctoken = cts.Token; try { var millisDelay = TextChangedDelay > 0 ? TextChangedDelay : 650; await Task.Delay(millisDelay, ctoken); if (ctoken.IsCancellationRequested) { return; } if (TextChangedCommand.CanExecute(null)) { TextChangedCommand?.Execute(null); } } catch (OperationCanceledException) { // Expected } } }
void OnTextChanged(object sender, TextChangedEventArgs e) { if (TextChangedCommand == null) { return; } var param = AssociatedObject.Text; if (TextChangedCommand.CanExecute(param)) { TextChangedCommand.Execute(param); } }
private void ExtendedSearchBar_TextChanged(object sender, TextChangedEventArgs e) { try { var param = TextChangedCommandParameter ?? e.NewTextValue; if (TextChangedCommand != null && TextChangedCommand.CanExecute(param)) { TextChangedCommand.Execute(param); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public SearchBar() { TextChanged += (e, a) => { if (TextChangedCommand != null && TextChangedCommand.CanExecute(null)) { TextChangedCommand.Execute(null); } }; TextChanged += (e, a) => { if (AutoSearch) { if (SearchCommand != null && SearchCommand.CanExecute(null)) { SearchCommand.Execute(null); } } }; }