title: Update ObservableCollection on item property change
body: <p>I'm trying to get an <code>ObservableCollection</code> to fire the <code>CollectionChanged</code> event when a property of an item is changed. I have used the code from <a href="https://stackoverflow.com/a/5256827/2570590">here</a> to do it but maybe I have made an error in translating from C# to Vb.net. In any case <code>item_PropertyChanged</code> is not firing. What am I missing here?</p>
  
  <p>Code:</p>
  
  <pre><code>Imports System.ComponentModel
  Imports System.Collections.Specialized
  Imports System.Collections.ObjectModel
  
  Class MainWindow
  
      Public Class TrulyObservableCollection(Of T As INotifyPropertyChanged)
          Inherits ObservableCollection(Of T)
          Public Sub New()
              MyBase.New()
              AddHandler CollectionChanged, AddressOf TrulyObservableCollection_CollectionChanged
          End Sub
  
          Private Sub TrulyObservableCollection_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
              If e.NewItems IsNot Nothing Then
                  For Each item As [Object] In e.NewItems
                      AddHandler TryCast(item, INotifyPropertyChanged).PropertyChanged, AddressOf item_PropertyChanged
                  Next
              End If
              If e.OldItems IsNot Nothing Then
                  For Each item As [Object] In e.OldItems
                      RemoveHandler TryCast(item, INotifyPropertyChanged).PropertyChanged, AddressOf item_PropertyChanged
                  Next
              End If
          End Sub
  
          Private Sub item_PropertyChanged(sender As Object, e As PropertyChangedEventArgs)
              Dim a As New NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)
              OnCollectionChanged(a)
          End Sub
      End Class
  
      Public Class edm
          Implements INotifyPropertyChanged
          Property ip As String
          Property status As String
          Public Sub New(ip As String, status As String)
              Me.ip = ip
              Me.status = status
          End Sub
  
          Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
      End Class
  
      Public Property edms As New TrulyObservableCollection(Of edm)
  
      Public Sub New()
  
          ' This call is required by the designer.
          InitializeComponent()
  
          ' Add any initialization after the InitializeComponent() call.
          DataContext = Me
          edms.Add(New edm("192.168.1.111", "On"))
          edms.Add(New edm("192.168.1.112", "Off"))
          edms.Add(New edm("192.168.1.113", "On"))
  
      End Sub
  
      Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
          edms.Where(Function(edm) edm.ip = "192.168.1.111").First().status = "Off"
      End Sub
  End Class
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Both Bjørn and Liero provided great answers and in this situation I find it difficult to mark one as correct and not the other so my reasoning for my choice is that while Bjørn's post answered my question as I put it, I marked Liero's answer, since his comments guided me to the best solution for my scenario.</p>