public SearchNavigationPage()
        {
            InitializeComponent ();

            service = new InMemoryIncidentService (Constants.Incidents);

            // wire up incidents SearchBar
            incidentsSb.TextChanged += (sender, e) => {
                if (!string.IsNullOrEmpty (incidentsSb.Text))
                    incidentsLv.ItemsSource = SearchIncidents (incidentsSb.Text);
                else
                    incidentsLv.ItemsSource = service.RetrieveIncidents ();
            };

            incidentsSb.SearchButtonPressed += (sender, e) => {
                if (!string.IsNullOrEmpty (incidentsSb.Text))
                    incidentsLv.ItemsSource = SearchIncidents (incidentsSb.Text);
                else
                    incidentsLv.ItemsSource = service.RetrieveIncidents ();
            };

            // wire up incidents ListView
            incidentsLv.ItemsSource = service.RetrieveIncidents ();

            incidentsLv.ItemSelected += async (sender, e) => {
                if (e.SelectedItem != null)
                    await Navigation.PushAsync (new IncidentsPage (e.SelectedItem as Incident));

                incidentsLv.SelectedItem = null;
            };
        }
        public IncidentsSearchDetailVm(IIncidentService svc)
        {
            Title = "Search Incidents";
            service = svc;

            Incidents = new ObservableCollection<Incident>(service.RetrieveIncidents ());
        }
        public SearchPage()
        {
            Title = "Incidents";

            this.Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 0);

            label = new Label { Text = "Incidents", HorizontalOptions = LayoutOptions.CenterAndExpand };
            service = new InMemoryIncidentService (Constants.Incidents);

            listview = new ListView ();
            listview.ItemsSource = service.RetrieveIncidents ();

            searchbar = new SearchBar () {
                Placeholder = "Search",
            };

            searchbar.TextChanged += (sender, e) => {
                if (!string.IsNullOrEmpty (searchbar.Text))
                    listview.ItemsSource = SearchIncidents (searchbar.Text);
                else
                    listview.ItemsSource = service.RetrieveIncidents ();
            };

            searchbar.SearchButtonPressed += (sender, e) => {
                if (!string.IsNullOrEmpty (searchbar.Text))
                    listview.ItemsSource = SearchIncidents (searchbar.Text);
                else
                    listview.ItemsSource = service.RetrieveIncidents ();

            };

            var stack = new StackLayout () {
                Orientation = StackOrientation.Vertical,
                Children = {
                    label,
                    searchbar,
                    listview
                }
            };

            Content = stack;
        }
        public SearchPageCustomTemplate()
        {
            InitializeComponent ();

            service = new InMemoryIncidentService (Constants.Incidents);
            incidentsLV.ItemsSource = service.RetrieveIncidents ();

            searchBar.TextChanged += (sender, e) => {
                if (!string.IsNullOrEmpty (searchBar.Text))
                    incidentsLV.ItemsSource = SearchIncidents (searchBar.Text);
                else
                    incidentsLV.ItemsSource = service.RetrieveIncidents ();
            };

            searchBar.SearchButtonPressed += (sender, e) => {
                if (!string.IsNullOrEmpty (searchBar.Text))
                    incidentsLV.ItemsSource = SearchIncidents (searchBar.Text);
                else
                    incidentsLV.ItemsSource = service.RetrieveIncidents ();
            };
        }