GridViewColumn not subscribing to PropertyChanged event in a ListView

I have a ListView with a GridView that's bound to the properties of a class that implements INotifyPropertyChanged, like this:

<ListView Name="SubscriptionView" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" ItemsSource="{Binding Path=Subscriptions}">
    <ListView.View>
        <GridView>
            <GridViewColumn Width="24" CellTemplate="{StaticResource IncludeSubscriptionTemplate}"/>
            <GridViewColumn Width="150" DisplayMemberBinding="{Binding Path=Name}" Header="Subscription"/>
            <GridViewColumn Width="75" DisplayMemberBinding="{Binding Path=RecordsWritten}" Header="Records"/>
            <GridViewColumn Width="Auto" CellTemplate="{StaticResource FilenameTemplate}"/>
        </GridView>
    </ListView.View>
</ListView>

The class looks like this:

public class Subscription : INotifyPropertyChanged
{
    public int RecordsWritten
    {
        get
        {
            return _records;
        }
        set
        {
            _records = value;
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("RecordsWritten"));
        }
    }
    private int _records;

    ...
}

So I fire up a BackgroundWorker and start writing records, updating the RecordsWritten property and expecting the value to change in the UI, but it doesn't. In fact, the value of PropertyChanged on the Subscription objects is null. This is a puzzler, because I thought WPF is supposed to subscribe to the PropertyChanged event of data objects that implement INotifyPropertyChanged. Am I doing something wrong here?

Answers


Figured out the problem. The "Subscriptions" list was coming from a LINQ query. When I added .ToList() to the end of that query, the UI started updating properly.


Need Your Help

Primefaces DialogFramework Growl and showMessageInDialog not working

java ajax jsf primefaces dialog

I am using primefaces dialogFramework. I have a Table.xhtml file as follows

How do I resolve "incompatible library version" for mysql2 gem with ruby 2.3 on OS X?

ruby-on-rails ruby mysql2

I'm using ruby 2.3, and in the gemfile, I've got the mysql2 gem listed. But when I try to run rake db:migrate, I get the following: