[Solved] How can I use combobox with wpf mvvm


Your code in LocationFilter make no sense at all.

ParticularEntries.Select(pg => pg.Region.Location == _selectedLocation);

It returns an IEnumerable<bool> but it is never assigned.

If you want to filter, you have to use Where.

But even if you change your code to

ParticularEntries = ParticularEntries.Where(pg => pg.Region.Location == _selectedLocation);

you will see a change, but you will face the next problem next time when you select a different location.

Solution

You need a collection with all unfiltered items stored inside a private field and use that for filtering.

private IEnumerable<EntryReportParticular> _allEntries;

private IEnumerable<EntryReportParticular> _particularEntries;
public IEnumerable<EntryReportParticular> ParticularEntries
{
    get { return _particularEntries; }
    set { Set(ref _particularEntries, value); }
}

private void LocationFilter()
{
   ParticularEntries = _allEntries
       .Where(pg => pg.Region.Location == _selectedLocation)
       .ToList();
}

0

solved How can I use combobox with wpf mvvm