title: WPF / C# Updating property change of an item in an ObservableCollection to the ListBox
body: <p>I have a list box:</p>
  
  <pre><code>&lt;ListBox x:Name="lbxAF" temsSource="{Binding}"&gt;
  </code></pre>
  
  <p>that gets its data from this from this modified Observable Collection:</p>
  
  <pre><code>public ObservableCollectionEx&lt;FileItem&gt; folder = new ObservableCollectionEx&lt;FileItem&gt;();
  </code></pre>
  
  <p>which is created within a class that uses FileSystemWatcher to monitor a specific folder for addition, deletion and modification of files.</p>
  
  <p>The ObservableCollection was modified (hence the Ex at the end) so that I can modify it from an outside thread (code is not mine, I actually did some searching through this website and found it, works like a charm):</p>
  
  <pre><code>    // This is an ObservableCollection extension
      public class ObservableCollectionEx&lt;T&gt; : ObservableCollection&lt;T&gt;
      {
          // Override the vent so this class can access it
          public override event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanged;
  
          protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
          {
              using (BlockReentrancy())
              {
                  System.Collections.Specialized.NotifyCollectionChangedEventHandler eventHanlder = CollectionChanged;
                  if (eventHanlder == null)
                      return;
  
                  Delegate[] delegates = eventHanlder.GetInvocationList();
  
                  // Go through the invocation list
                  foreach (System.Collections.Specialized.NotifyCollectionChangedEventHandler handler in delegates)
                  {
                      DispatcherObject dispatcherObject = handler.Target as DispatcherObject;
  
                      // If the subscriber is a DispatcherObject and different thread do this:
                      if (dispatcherObject != null &amp;&amp; dispatcherObject.CheckAccess() == false)
                      {
                          // Invoke handler in the target dispatcher's thread
                          dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, this, e);
                      }
                      // Else, execute handler as is
                      else
                      {
                          handler(this, e);
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>The collection is made up of these:</p>
  
  <pre><code>public class FileItem
  {
      public string Name { get; set; }
      public string Path { get; set; }
  }
  </code></pre>
  
  <p>which allow me to store names and paths of files.</p>
  
  <p>Everything works great as far as deletion and addition of files, and the List Box gets updated flawlessly with respect to those two... <strong>however</strong>, if I change the name of any of the files, it doesn't update the list box.</p>
  
  <p>How would I notify list box of the changes in FileItem's properties?  I assumed that ObservableCollection would handle that, but apparently it raises flag only when FileItem is added or deleted, not when its contents are changed.</p>