private void _searchBar_CancelButtonClicked(object sender, EventArgs e) { _searchBar.Text = string.Empty; _searchBar.ShowsCancelButton = false; _searchBar.EndEditing(true); UpdateSearchResultsForSearchController(sender, e); }
private void CreateLayout() { // Create the extent query button and subscribe to events _myQueryExtentButton = new UIButton(); _myQueryExtentButton.SetTitle("Count in Extent", UIControlState.Normal); _myQueryExtentButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); _myQueryExtentButton.TouchUpInside += BtnCountFeatures_Click; // Create the state query button and subscribe to events _myQueryStateButton = new UIButton(); _myQueryStateButton.SetTitle("Zoom to match", UIControlState.Normal); _myQueryStateButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); _myQueryStateButton.TouchUpInside += BtnZoomToFeatures_Click; // Create the results label and the search bar _myResultsLabel = new UILabel() { TextColor = UIColor.Red }; _myStateEntry = new UISearchBar() { Placeholder = "e.g. NH" }; // Allow the search bar to dismiss the keyboard _myStateEntry.SearchButtonClicked += (sender, e) => { _myStateEntry.EndEditing(true); }; // Add views to the page View.AddSubviews(_myMapView, _myQueryExtentButton, _myQueryStateButton, _myResultsLabel, _myStateEntry); }
public SearchView(SearchViewController parent) { Parent = parent; var style = this.GetStyle(); searchBar = new UISearchBar { BarTintColor = UIColor.White, TintColor = style.AccentColor, AccessibilityIdentifier = "searchBar", }; searchBar.CancelButtonClicked += (sender, args) => { var search = (sender as UISearchBar); var s = search.Superview as SearchView; s.Parent.Model.Search(""); searchBar.ResignFirstResponder(); }; searchBar.SearchButtonClicked += (sender, args) => { var search = (sender as UISearchBar); var s = search.Superview as SearchView; s.Parent.Model.Search(searchBar.Text); searchBar.ResignFirstResponder(); }; searchBar.TextChanged += (object sender, UISearchBarTextChangedEventArgs e) => { var search = (sender as UISearchBar); var s = search.Superview as SearchView; if (search.Text != "") { s.Parent.Model.KeyPressed(search.Text); return; } s.Parent.Model.Search(""); this.BeginInvokeOnMainThread(() => { searchBar.EndEditing(true); searchBar.ResignFirstResponder(); }); }; PanaramBarController = new TopTabBarController(); Add(PanaramBarController.View); parent.AddChildViewController(PanaramBarController); PanaramBarController.ViewControllers = Parent.Model.ViewModels.Select(x => new SearchListViewController { Model = x }).ToArray(); Add(searchBar); }
private void Control_ShouldBeginEditing(UISearchBar control) {//keyboard dismiss control.EndEditing(true); }
public override void SearchButtonClicked(UISearchBar searchBar) { _searchbar.EndEditing(true); }
public void ClearSearchBar() { searchBar.Text = ""; searchBar.EndEditing(true); }