public SearchDisplayDelegate (SearchViewModel searchViewModel) { this.searchViewModel = searchViewModel; searchViewModel.SearchCompleted += HandleSearchCompleted; searchViewModel.Error += HandleError; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.SearchActivity); searchViewModel = new SearchViewModel (Android.Application.Service, new Search ("Default")) { GroupByLastName = false, }; searchViewModel.SearchCompleted += HandleSearchCompleted; progressBar = FindViewById<ProgressBar> (Resource.Id.progressBar1); searchingText = FindViewById<TextView> (Resource.Id.emptyTextView); ListAdapter = new PeopleGroupsAdapter () { ItemsSource = searchViewModel.Groups, }; // Start the search var intent = Intent; if (!Intent.ActionSearch.Equals (intent.Action)) return; searchViewModel.SearchText = intent.GetStringExtra (SearchManager.Query); searchViewModel.SearchProperty = SearchProperty.All; searchViewModel.Search (); }
public SearchListXaml () { InitializeComponent (); var task = Task.Run(async () => { favoritesRepository = await XmlFavoritesRepository.OpenFile ("XamarinFavorites.xml"); }); task.Wait(); search = new Search ("test"); viewModel = new SearchViewModel (App.Service, search); viewModel.SearchCompleted += (sender, e) => { if (viewModel.Groups == null) { listView.ItemsSource = new string [1]; } else { listView.ItemsSource = viewModel.Groups; } }; viewModel.Error += (sender, e) => { DisplayAlert ("Error", e.Exception.Message, "OK", null); }; BindingContext = viewModel; }
public SearchPage () { InitializeComponent (); DataContext = new SearchViewModel (App.Current.DirectoryService, App.Current.SavedSearch) { SearchProperty = SearchProperty.All, }; Loaded += HandleLoaded; }
private void InitializeViewModel () { var task = Task.Run(async () => { favoritesRepository = await XmlFavoritesRepository.OpenFile ("XamarinFavorites.xml"); }); task.Wait(); search = new Search (string.Empty); viewModel = new SearchViewModel (App.Service, search); viewModel.SearchCompleted += OnSearchCompleted; viewModel.Error += (sender, e) => { DisplayAlert ("Help", e.Exception.Message, "OK", null); }; BindingContext = viewModel; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.SearchActivity); // // Initialize the service // //var service = new LdapDirectoryService { // Host = "ldap.mit.edu", // SearchBase = "dc=mit,dc=edu", //}; searchViewModel = new SearchViewModel (Android.Application.Service, new Search ("Default")) { GroupByLastName = false, }; searchViewModel.SearchCompleted += HandleSearchCompleted; progressBar = FindViewById<ProgressBar> (Resource.Id.progressBar1); searchingText = FindViewById<TextView> (Resource.Id.emptyTextView); // // Construct the UI // ListAdapter = new PeopleGroupsAdapter () { ItemsSource = searchViewModel.Groups, }; // // Start the search // var intent = Intent; if (Intent.ActionSearch.Equals (intent.Action)) { var query = intent.GetStringExtra (SearchManager.Query); searchViewModel.SearchText = query; searchViewModel.SearchProperty = SearchProperty.All; searchViewModel.Search (); } }
public FavoritesViewController(IFavoritesRepository favoritesRepository, IDirectoryService service, Search savedSearch) { this.favoritesRepository = favoritesRepository; Title = "Favorites"; viewModel = new FavoritesViewModel (favoritesRepository, groupByLastName: true); viewModel.PropertyChanged += HandleViewModelPropertyChanged; searchViewModel = new SearchViewModel (service, savedSearch); // // Configure this view // var favoritesDelegate = new PeopleGroupsDelegate (TableView); favoritesDelegate.PersonSelected += HandlePersonSelected; TableView.DataSource = new PeopleGroupsDataSource (viewModel.Groups); TableView.Delegate = favoritesDelegate; TableView.SectionIndexMinimumDisplayRowCount = 10; // // Configure the search bar // searchBar = new UISearchBar (new CGRect (0f, 0f, 320f, 44f)) { ShowsScopeBar = true, }; searchBar.ScopeButtonTitles = new[] { "Name", "Title", "Dept", "All" }; searchBar.SelectedScopeButtonIndex = (int)savedSearch.Property; searchController = new UISearchDisplayController (searchBar, this) { SearchResultsDataSource = new PeopleGroupsDataSource (searchViewModel.Groups), Delegate = new SearchDisplayDelegate (searchViewModel) }; var searchDelegate = new PeopleGroupsDelegate (searchController.SearchResultsTableView); searchController.SearchResultsTableView.SectionIndexMinimumDisplayRowCount = 10; searchDelegate.PersonSelected += HandleSearchPersonSelected; searchController.SearchResultsDelegate = searchDelegate; TableView.TableHeaderView = searchBar; }
public SearchListXaml () { InitializeComponent (); favoritesRepository = XmlFavoritesRepository.OpenFile ("XamarinFavorites.xml").Result; search = new Search ("test"); viewModel = new SearchViewModel (App.Service, search); viewModel.SearchCompleted += (sender, e) => { if (viewModel.Groups == null) { // clear it out listView.ItemsSource = new string [1]; } else { listView.ItemsSource = viewModel.Groups; } }; viewModel.Error += (sender, e) => { // e.Exception }; BindingContext = viewModel; }