示例#1
0
        public ViewModel(IAppData appData)
        {
            _appData      = appData;
            SearchCommand = new RelayCommand(SearchFunc);

            if (appData.ProductTypes != null)
            {
                ProductTypes = appData.ProductTypes.Select(p => new ProductTypeModel(p));
            }

            SearchedProductTypes = ProductTypes.ToArray();

            appData.PropertyChanged +=
                (sender, args) =>
            {
                switch (args.PropertyName)
                {
                case "ProductTypes":
                    if (appData.ProductTypes != null)
                    {
                        ProductTypes = appData.ProductTypes.Select(p => new ProductTypeModel(p));
                    }

                    SearchedProductTypes = ProductTypes.ToArray();
                    break;
                }
            };
        }
示例#2
0
        public void SearchFunc(object parameter)
        {
            if (parameter != null)
            {
                SearchText = parameter.ToString();
            }

            SearchedProductTypes = string.IsNullOrEmpty(SearchText) ?
                                   ProductTypes.ToArray() :
                                   ProductTypes.Where(p => p.ProductType.BarCode.ToLower().Contains(SearchText.ToLower()) || p.ProductType.Name.ToLower().Contains(SearchText.ToLower())).ToArray();
        }