Esempio n. 1
0
        private void Search()
        {
            if (_lookup == null)
            {
                return;
            }
            if (!_lookup.Any())
            {
                return;
            }

            var searchItem = txtSearch.Text;

            if (searchItem.Trim().Length == 0)
            {
                _viewModel.Collection = _lookup;
                DataContext           = _viewModel;
            }
            else
            {
                var filteredItem = from item in _lookup
                                   where item.Title.ToLower().Contains(searchItem.ToLower())
                                   select item;

                var viewModel = new ReportItemViewModel {
                    Collection = new ReportItemCollection()
                };
                foreach (var item in filteredItem)
                {
                    viewModel.Collection.Add(item);
                }
                _viewModel  = viewModel;
                DataContext = _viewModel;
            }
        }