Hi Malcolm,
You can achieve your requirement by getting the filtered count from the SfListView.DataSource.DisplayItems. Please refer to the following code snippets for more reference,
ViewModel: Create a property to show the filtered items count
|
public class SortingFilteringViewModel : INotifyPropertyChanged
{
…
public SortingFilteringViewModel()
{
AddItemDetails();
Count = Items.Count;
}
public int Count
{
get { return count; }
set { count = value; OnPropertyChanged("Count"); }
}
} |
XAML: Bind the Count property. And using converter, you can format the text based on your requirement.
|
<Grid BackgroundColor="DarkGoldenrod" Grid.Row="1">
<Label Text="{Binding Count, Converter={StaticResource HeaderTextConverter},
ConverterParameter={x:Reference viewModel}}"
HorizontalOptions="Center" VerticalOptions="Center"
FontAttributes="Bold" FontSize="Caption" TextColor="White"/>
</Grid> |
Behavior: In the TextChanged event, update the count property after filter.
|
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
{
searchBar = (sender as SearchBar);
sortingFilteringViewModel = searchBar.BindingContext as SortingFilteringViewModel;
if (ListView.DataSource != null)
{
ListView.DataSource.Filter = FilterContacts;
ListView.DataSource.RefreshFilter();
}
ListView.RefreshView();
sortingFilteringViewModel.Count = ListView.DataSource.DisplayItems.Count;
} |
We have prepared a sample to achieve your requirement and attached in the following link,
Screenshot
Regarding 404 error, we are checking the same with our internal team. We will let you know when its fixed.
Please let us know if you need further assistance.
Regards,
Lakshmi Natarajan