I update your ViewModel
to let the ListView show specified items when the query condition is null.
public class ViewMode
{
public ViewModel()
{
maxShowItems = 20;
for (int i=0;i<40000;i++)
{
EmailList.Add(new Person() { ID = i, FirstName = "Rose"+i.ToString(), LastName = "Bob", EmailId = "132165410@ss.com" });
}
PersonListView = new ListCollectionView(EmailList);
PersonListView.Filter += Filter;
}
private bool Filter(object obj)
{
Person person = obj as Person;
if (person == null) return false;
if (PersonListView.Count > maxShowItems && string.IsNullOrEmpty(ldapFilter))
{
if (person.ID < maxShowItems)
{
return true;
}
return false;
}
if (string.IsNullOrEmpty(ldapFilter))
{
return true;
}
else
{
if (person.FirstName.Contains(ldapFilter))
{
return true;
}
return false;
}
}
public ListCollectionView PersonListView { get; set; }
public ObservableCollection<Person> emailList = new ObservableCollection<Person>();
public ObservableCollection<Person> EmailList
{
get { return emailList; }
set
{
if (value != emailList)
{
emailList = value;
OnPropertyChanged("EmailLIst");
}
}
}
private string ldapFilter;
public string LdapFilter
{
get { return ldapFilter; }
set
{
if (value != ldapFilter)
{
ldapFilter = value;
this.PersonListView.Refresh();
//FilterResults();
OnPropertyChanged("LdapFilter");
}
}
}
private int maxShowItems;
public int MaxShowItems
{
get { return maxShowItems; }
set
{
if (value != maxShowItems)
{
maxShowItems = value;
this.PersonListView.Refresh();
OnPropertyChanged("MaxShowItems");
}
}
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.