正在开发一个拥有SearchBar的XF项目。 XAML宣言如下所示。
$scope.GetAngValue = function (value) {
var Matches = value.match(/\<(.*?)\>/);
if (Matches) {
$scope.Result = Matches[1];
}
}
在ViewModel,我有以下声明的
<SearchBar Placeholder="Result" Text="{Binding SearchedCustomer,Mode=TwoWay}"
SearchCommand="{Binding SearchCustomerCommand}"></SearchBar>
我还在构造函数中创建了SearchCustomerCommand,如下所示
private string _SearchedCustomer;
public string SearchedCustomer
{
get { return _SearchedCustomer; }
set { SetProperty(ref _SearchedCustomer, value); }
}
public DelegateCommand SearchCustomerCommand { get; set; }
private ObservableCollection<CustomerModel> _CustomerList;
public ObservableCollection<CustomerModel> CustomerList
{
get
{
if (_CustomerList == null)
FillCustomerDetails();
return _CustomerList;
}
set { SetProperty(ref _CustomerList, value); }
}
private void ExecuteSearchCustomerCommand()
{
var tempRecords = _CustomerList.Where(c => c.ReferenceText.Contains(SearchedCustomer));
CustomerList.Clear();
foreach (var item in tempRecords)
{
CustomerList.Add(item);
}
}
当我输入SearchBar时,SearchedCustomer字段会被更改,但是,Command SearchCustomerCommand不会被执行。
有人可以帮助我确定我在这里做错了吗?