I'm having trouble showing the actual number of items in my grid. When the application loads there are no items. The grid is bound to an ObservableCollection. When the user selects a query option from a list, the ViewModel clears the OC and adds the result items from the chosen query. This is done via background worker, then the results are cast to an IList and added to the collection via the OC.Add method.
What I want to do is show the user how many items are in the grid at any given time. It's working to some extent. As long as I don't change the initial query, it works. I have a textblock binding to the GridView's Items.ItemCount property.
The problem comes when I filter the results, then try to do a different query. The GridView's ItemCount isn't updating appropriately. Sometimes it shows 0 when there are clearly 3 items in the grid. If I clear the filters or change the filters for that query, the number gets reset and from them on it works properly, until I change the query.
For example, one query returns all records. There are 73. If I filter the grid on a status column to show all closed, it tells me there are 19. If I then try to run a different query, this one shows 3 items in the grid (because there are 3 items with closed status). The grid keeps the filtering and applies it to the new results. But the count shows 0. If I then change back to the original all records query, the count shows 1 even though the original 19 filtered records are once again shown in the grid.
So how do I get the correct count no matter how the grid is populated or filtered? I can't bind to the count of the bound collection, because if the user filters the grid, I want to show the filtered total. Basically (the total items that are displayed or visible).
What I want to do is show the user how many items are in the grid at any given time. It's working to some extent. As long as I don't change the initial query, it works. I have a textblock binding to the GridView's Items.ItemCount property.
The problem comes when I filter the results, then try to do a different query. The GridView's ItemCount isn't updating appropriately. Sometimes it shows 0 when there are clearly 3 items in the grid. If I clear the filters or change the filters for that query, the number gets reset and from them on it works properly, until I change the query.
For example, one query returns all records. There are 73. If I filter the grid on a status column to show all closed, it tells me there are 19. If I then try to run a different query, this one shows 3 items in the grid (because there are 3 items with closed status). The grid keeps the filtering and applies it to the new results. But the count shows 0. If I then change back to the original all records query, the count shows 1 even though the original 19 filtered records are once again shown in the grid.
So how do I get the correct count no matter how the grid is populated or filtered? I can't bind to the count of the bound collection, because if the user filters the grid, I want to show the filtered total. Basically (the total items that are displayed or visible).