Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6856473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:53:26+00:00 2026-05-27T01:53:26+00:00

When I have a <Label Content={Binding ItemCount}/> on my View to bind to a

  • 0

When I have a <Label Content="{Binding ItemCount}"/> on my View to bind to a property on the ViewModel.

On the viewmodel I have the property defined as

public int ItemCount
{
    get { RowViewModelsCollectionView.Count; }
}

I am clearly asking for count on the CollectionView, where I am expecting to get the count of only visible items. Unfortunately I get the count of the entire rows, even the ones not showing on the view due the filter.

Update:

in Ctor:

RowViewModelsCollectionView= new ListCollectionView(rowViewModels) {Filter = Contains};


private bool Contains(object obj)
        {
            RowViewModel rowViewModel = obj as RowViewModel;

            if (rowViewModel != null && Books.ContainsKey(rowViewModel.Book))
            {
                RaisePropertyChanged("ItemCount"); // Trying out to raise it without joy
                return true;
            }

            return false;
        }

How should I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:53:27+00:00Added an answer on May 27, 2026 at 1:53 am

    why don’t you use this?

    <Label Content="{Binding ModelView.RowViewModelsCollectionView.Count}"/>
    

    This is a little example.

    <Window x:Class="WPFValidation.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window"
            Height="300"
            Width="300">
      <Grid>
    
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition />
        </Grid.RowDefinitions>
    
        <TextBox Grid.Row="0"
                 Text="{Binding FilterText, UpdateSourceTrigger=PropertyChanged}" />
        <TextBlock Grid.Row="1"
                   Text="{Binding ModelListView.Count}" />
        <ListBox Grid.Row="2"
                 ItemsSource="{Binding ModelListView}" />
    
      </Grid>
    </Window>
    
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Windows;
    using System.Windows.Data;
    
    namespace WPFValidation
    {
      /// <summary>
      /// Interaction logic for MainWindow.xaml
      /// </summary>
      public partial class MainWindow : Window
      {
        public MainWindow() {
          this.DataContext = new ModelView();
          this.InitializeComponent();
        }
      }
    
      public class ModelView : INotifyPropertyChanged
      {
        public event PropertyChangedEventHandler PropertyChanged;
    
        private ICollectionView modelListView;
    
        private ICollection<string> collection;
    
        public ModelView() {
          this.collection = new ObservableCollection<string>(new[] {"test1", "test2", "filtering"});
        }
    
        public ICollectionView ModelListView {
          get { return this.modelListView ?? this.GetModelListView(); }
        }
    
        private ICollectionView GetModelListView() {
          var collectionView = CollectionViewSource.GetDefaultView(this.collection);
          collectionView.Filter += o => o == null || string.IsNullOrEmpty(this.FilterText) || o.Equals(this.FilterText);
          return collectionView;
        }
    
        private string filterText;
    
        public string FilterText {
          get { return this.filterText; }
          set {
            if (value != this.filterText) {
              this.filterText = value;
              this.ModelListView.Refresh();
              this.RaisePropertyChange("FilterText");
            }
          }
        }
    
        private void RaisePropertyChange(string propertyName) {
          var eh = this.PropertyChanged;
          if (eh != null) {
            eh(this, new PropertyChangedEventArgs(propertyName));
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In My ViewModel class I have a property: class ViewModel : INotifyPropertyChanged { public
I have a Label: <Label Name=lblBilledDate Content={Binding Path=BilledDate, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}> </Label> It is bound
I have the following XAML: <sdk:Label Content={Binding RefreshTextToggle, Converter={StaticResource enumToText}, ConverterParameter=ItemsOfInterest,FallbackValue='Please select items of
I have a label in WPF4 and trying to bind the content to a
I have a Label, whose content is displayed by a while loop. when i
HI i have created a content type call mycontent it has 2 fields Label:
i have a label in my form, and im trying to get the value
I have a label that is using a repeater to get information form a
I have this very simple XAML window: <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <ContentControl Content={Binding
I have learned how to format strings in the content attribute of a label

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.