I am applying a filter programmatically to a Telerik GridView so that only those records which match the selection
should be shown. My predicate seems to be filtering the results correctly but my source collection is never filtered. Here is my
sample code:
//Setting Data Context here
internal void BuildReportObjectCollection()
{
List<ReportObjectEntity> reportObjectCollection =
Presenter.buildReportObjectCollection();
SingleObjectList.DataContext = reportObjectCollection;
}
//Use the list of Guids to filter my collection using
//the predicate here
public void Show(List<Guid> reportObjectList)
{
selectdReportObjectCollection = reportObjectList;
if (selectdReportObjectCollection != null)
{
if (SingleObjectList.ItemsSource != null)
{
// filter
collectionView =
CollectionViewSource.GetDefaultView(SingleObjectList.DataContext);
collectionView.Filter =
new Predicate<object>(FilterForSelectedReportObjectList);
}
}
}
public
bool FilterForSelectedReportObjectList(object item)
{
ReportObjectEntity reportObject = item as ReportObjectEntity;
if (reportObject != null && this.selectdReportObjectCollection.Contains(reportObject.ReportObjectID))
{
return true;
}
else
{
return false;
}
}
//The XAML is pretty standard for the GridView, ItemsSource = {Binding}
Does anyone know what is the issue here?
Thanks,