public MainPage() { this.InitializeComponent(); var textChanges = Observable.FromEventPattern<TextChangedEventArgs>(this.TextInputBox, "TextChanged").Select(e => ((TextBox)e.Sender).Text).Throttle(new TimeSpan(0, 0, 1)); textChanges.ObserveOn(this).Subscribe(lookup => { Suggestions suggestions = new Suggestions(); SuggestionsList.Items.Clear(); foreach (var suggestion in suggestions.FindSuggestions(lookup)) { SuggestionsList.Items.Add(suggestion); } }); }
public MainPage() { this.InitializeComponent(); var textChanges = Observable.FromEventPattern <TextChangedEventArgs>(this.TextInputBox, "TextChanged").Select(e => ((TextBox)e.Sender).Text).Throttle(new TimeSpan(0, 0, 1)); textChanges.ObserveOn(this).Subscribe(lookup => { Suggestions suggestions = new Suggestions(); SuggestionsList.Items.Clear(); foreach (var suggestion in suggestions.FindSuggestions(lookup)) { SuggestionsList.Items.Add(suggestion); } }); }
public Form1() { InitializeComponent(); var textChange = Observable.FromEventPattern<EventArgs> (this.textBox1, "TextChanged"). Select(evt=>((TextBox)evt.Sender).Text). Where(s=>s.Length >= 3) .DistinctUntilChanged(); textChange.Subscribe(input => { Suggestions suggs = new Suggestions(); this.listBox1.Items.Clear(); foreach (var suggestion in suggs.FindSuggestions(input)) { listBox1.Items.Add(suggestion); } }); }