ListCollectionView lcv2 = (ListCollectionView)CollectionViewSource.GetDefaultView(DataGrid.ItemsSource);
if (_searchTextBoxText != null)
lcv2.Filter = new Predicate<object>(FilterFields);
else
lcv2.Filter = null;
DataGrid.Dispatcher.BeginInvoke(new Action(delegate
{
DataGrid.ItemsSource = lcv2;
}));
Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
// Код, работающий в UI потоке
});
Dispatcher.BeginInvoke(new Action(delegate
{
lcv2.Filter = item =>
{
int count = item.GetType().GetProperties().Count<object>();
bool result = false;
for (int i = 0; i < count; i++)
if (item.GetType().GetProperties()[i].GetValue(item, null).ToString().Contains(_searchTextBoxText))
result = true;
return result;
};
}), System.Windows.Threading.DispatcherPriority.Background);