예제 #1
0
 public ExtendedEntry()
 {
     TextChanged += (sender, e) =>
     {
         TextChangedCommand?.Execute(e);
     };
 }
예제 #2
0
        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);
                        }
                    };
                }
            }));
        }
예제 #3
0
 void OnEntryTextChanged(object sender, TextChangedEventArgs args)
 {
     if (TextChangedCommand != null)
     {
         TextChangedCommand.Execute(new Tuple <object, TextChangedEventArgs>(sender, args));
     }
 }
예제 #4
0
        private void BorderlessEntry_Unfocused(object sender, FocusEventArgs e)
        {
            IsHeaderVisible     = !string.IsNullOrEmpty((sender as Entry)?.Text);
            InternalPlaceholder = IsHeaderVisible ? string.Empty : Placeholder;
            InternalBorderColor = BorderColor;

            if (!IsHeaderVisible)
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await FrameHeader.FadeTo(0, length: 100);
                });
            }

            if (Text != null)
            {
                if (Text.Validations?.Any() == true)
                {
                    Text.Validate();

                    IsValidationVisible = !Text.IsValid;
                }
            }

            TextChangedCommand?.Execute(Text);
        }
예제 #5
0
        private void TextChangedDelayTimer_Tick(object sender, EventArgs e)
        {
            textChangedDelayTimer.Stop();

            if (TextChangedCommand != null && TextChangedCommand.CanExecute(null))
            {
                TextChangedCommand.Execute(null);
            }
        }
예제 #6
0
        private void BorderlessEntry_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextChangedCommand?.Execute(Text);

            if (Text != null)
            {
                Text.IsValid = true;
            }
        }
예제 #7
0
        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
                }
            }
        }
예제 #8
0
        void OnTextChanged(object sender, TextChangedEventArgs e)
        {
            if (TextChangedCommand == null)
            {
                return;
            }

            var param = AssociatedObject.Text;

            if (TextChangedCommand.CanExecute(param))
            {
                TextChangedCommand.Execute(param);
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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);
                    }
                }
            };
        }
예제 #11
0
 private void ExtendedEntry_TextChanged(object sender, TextChangedEventArgs e)
 {
     TextChangedCommand?.Execute(e.NewTextValue);
 }
예제 #12
0
 private void BorderlessEntry_TextChanged(object sender, TextChangedEventArgs e)
 {
     IsClearVisible = !string.IsNullOrEmpty(Text);
     TextChangedCommand?.Execute(Text);
 }
예제 #13
0
 public CustomAutoSuggest()
 {
     TextChanged += (sender, e) => TextChangedCommand?.Execute(null);
 }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AutoCompleteView"/> class.
        /// </summary>
        public AutoCompleteView()
        {
            _availableSuggestions = new ObservableCollection <object>();
            _stkBase = new StackLayout();
            var innerLayout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };

            _entText = new Entry
            {
                HorizontalOptions = TextHorizontalOptions,
                VerticalOptions   = TextVerticalOptions,
                TextColor         = TextColor,
                BackgroundColor   = TextBackgroundColor
            };
            _btnSearch = new Button
            {
                VerticalOptions   = SearchVerticalOptions,
                HorizontalOptions = SearchHorizontalOptions,
                Text = SearchText
            };

            _lstSuggestions = new ListView
            {
                HeightRequest = SuggestionsHeightRequest,
                HasUnevenRows = true
            };

            innerLayout.Children.Add(_entText);
            innerLayout.Children.Add(_btnSearch);
            _stkBase.Children.Add(innerLayout);
            _stkBase.Children.Add(_lstSuggestions);

            Content = _stkBase;


            _entText.TextChanged += (s, e) =>
            {
                Text = e.NewTextValue;
                TextChangedCommand.Execute(e.NewTextValue);
                OnTextChanged(e);
            };
            _btnSearch.Clicked += (s, e) =>
            {
                if (SearchCommand != null && SearchCommand.CanExecute(Text))
                {
                    SearchCommand.Execute(Text);
                }
            };
            _lstSuggestions.ItemSelected += (s, e) =>
            {
                _entText.Text = e.SelectedItem.ToString();

                _availableSuggestions.Clear();
                ShowHideListbox(false);
                OnSelectedItemChanged(e.SelectedItem);

                if (ExecuteOnSuggestionClick &&
                    SearchCommand != null &&
                    SearchCommand.CanExecute(Text))
                {
                    SearchCommand.Execute(e);
                }
            };
            ShowHideListbox(false);
            _lstSuggestions.ItemsSource = _availableSuggestions;
        }
 public BorderEntry()
 {
     TextChanged += (sender, e) => TextChangedCommand?.Execute(e);
 }