public OpportunitiesPage() { _opportunitiesViewModel = new OpportunitiesViewModel(); BindingContext = _opportunitiesViewModel; #region Create the ListView _listView = new ListView() { ItemTemplate = new DataTemplate(typeof(OpportunitiesViewCell)), RowHeight = 75 }; _listView.IsPullToRefreshEnabled = true; _listView.Refreshing += (async(sender, e) => { await _opportunitiesViewModel.RefreshOpportunitiesDataAsync(); _listView.EndRefresh(); }); _listView.ItemSelected += (sender, e) => { Navigation.PushAsync(new CreditBuilderCarouselPage()); }; _listView.SetBinding(ListView.ItemsSourceProperty, "AllOpportunitiesData"); #endregion Title = $"Opportunities"; #region Initialize the Toolbar Add Button _addButtonToolBar = new ToolbarItem(); _addButtonToolBar.Icon = "Add"; _addButtonToolBar.AutomationId = AutomationIdConstants.AddOpportunityButton; ToolbarItems.Add(_addButtonToolBar); #endregion #region Create Searchbar var searchBar = new SearchBar(); searchBar.AutomationId = AutomationIdConstants.OpportunitySearchBar; searchBar.TextChanged += (sender, e) => _opportunitiesViewModel.FilterLocations(searchBar.Text); #endregion #region Create Stack var listSearchStack = new StackLayout { Padding = 0, Spacing = 0, Children = { searchBar, _listView } }; #endregion SubscribeEventHandlers(); Content = listSearchStack; }
public OpportunitiesPage() { opportunitiesViewModel = new OpportunitiesViewModel(); BindingContext = opportunitiesViewModel; #region Create the ListView listView = new ListView() { ItemTemplate = new DataTemplate(typeof(OpportunitiesViewCell)), RowHeight = 75 }; listView.IsPullToRefreshEnabled = true; listView.Refreshing += (async(sender, e) => { await opportunitiesViewModel.RefreshOpportunitiesData(); listView.EndRefresh(); }); listView.ItemSelected += (sender, e) => { Navigation.PushAsync(new CreditBuilderCarouselPage()); }; listView.SetBinding(ListView.ItemsSourceProperty, "AllOpportunitiesData"); #endregion Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); Title = $"Opportunities"; #region Initialize the Toolbar Add Button var addButtonToolBar = new ToolbarItem(); addButtonToolBar.Icon = "Add"; addButtonToolBar.Clicked += async(sender, e) => await Navigation.PushModalAsync(new NavigationPage(new AddOpportunityPage())); ToolbarItems.Add(addButtonToolBar); #endregion #region Create Searchbar var searchBar = new SearchBar(); searchBar.TextChanged += (sender, e) => opportunitiesViewModel.FilterLocations(searchBar.Text); #endregion #region Create Stack var listSearchStack = new StackLayout { Children = { searchBar, listView } }; #endregion Content = listSearchStack; }