添加项目文件。
This commit is contained in:
59
XXCpzs/Views/PageCustomerSelect.xaml.cs
Normal file
59
XXCpzs/Views/PageCustomerSelect.xaml.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
using XXCpzs.Models;
|
||||
using XXCpzs.Services;
|
||||
using XXCpzs.ViewModels;
|
||||
|
||||
namespace XXCpzs.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class PageCustomerSelect : ContentPage
|
||||
{
|
||||
SearchViewModel ViewModel;
|
||||
private UserInfo userInfo;
|
||||
|
||||
|
||||
public PageCustomerSelect(UserInfo userInfo)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.userInfo = userInfo;
|
||||
this.BindingContext = ViewModel = new SearchViewModel(userInfo.uid, this);
|
||||
searchResults.ItemsSource = CustomerDataService.GetSearchResults(searchBar.Text);
|
||||
}
|
||||
|
||||
void OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
searchResults.ItemsSource = CustomerDataService.GetSearchResults(e.NewTextValue);
|
||||
}
|
||||
|
||||
private async void searchResults_ItemSelectedAsync(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
|
||||
if (e.SelectedItem != null)
|
||||
{
|
||||
Customer customer = e.SelectedItem as Customer;
|
||||
bool response = await DisplayAlert("Item Selected", customer.company, "Yes", "No");
|
||||
if (response)
|
||||
{
|
||||
MessagingCenter.Send(this, "SelectCustomer", customer);
|
||||
await Navigation.PopModalAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
private async void Button_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
await Navigation.PushModalAsync(new NavigationPage(new PageAddCustomer(userInfo)));
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
searchResults.ItemsSource = CustomerDataService.GetSearchResults(searchBar.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user