private void InitialiseResults() { var resultsServiceHelper = new ServiceCallWrapper <string, IEnumerable <string> >(this.searchService.GetResultsForQuery); // Subscribing to events to trigger service call this.searchButton.Click += (s, e) => resultsServiceHelper.ServiceCall(this.searchBox.Text); this.suggestions.SelectionChanged += (s, e) => { if (e.AddedItems.OfType <string>().SingleOrDefault() is string selectedSuggestion) { resultsServiceHelper.ServiceCall(selectedSuggestion); } }; this.searchBox.KeyDown += (s, e) => { if (e.Key == Key.Enter) { resultsServiceHelper.ServiceCall(this.searchBox.Text); } }; // Registering callback methods resultsServiceHelper.CallBack += this.CallBack; resultsServiceHelper.ErrorCallBack += this.ErrorCallBack; }
private void InitialiseResults() { var resultsServiceHelper = new ServiceCallWrapper <string, IEnumerable <string> >(this.searchService.GetResultsForQuery); // Subscribing to events to trigger service call this.searchButton.Click += (s, e) => resultsServiceHelper.ServiceCall(this.searchBox.Text); this.suggestions.ItemClick += (s, e) => resultsServiceHelper.ServiceCall(e.ClickedItem as string); this.searchBox.KeyDown += (s, e) => { if (e.Key == VirtualKey.Enter) { resultsServiceHelper.ServiceCall(this.searchBox.Text); } }; // Registering callback methods resultsServiceHelper.CallBack += this.CallBack; resultsServiceHelper.ErrorCallBack += this.ErrorCallBack; }
private void InitialiseSuggestions() { var suggestionsServiceHelper = new ServiceCallWrapper <string, IEnumerable <string> >(this.searchService.GetSuggestionsForQuery); // Subscribing to events to trigger service call this.searchBox.TextChanged += (s, e) => suggestionsServiceHelper.ServiceCall(this.searchBox.Text); // Registering callback methods suggestionsServiceHelper.CallBack += this.CallBack; suggestionsServiceHelper.ErrorCallBack += this.ErrorCallBack; }