0

Dotnet 4.5 was rolled out to our organisation. Post upgrade my one WPF tool is broken (one grid doesn't display anything).

The application has a few datagrids bound to different sources. Each of the sources are identical except for the datatype.

All the other sources are working 100%.

I can see the collection contains data simply is not updating the datagrid. I have swapped the grid out for a standard ListBox and there is no change.

It seems that replacing the value with the whole collection isn't working. If I iterated and add items to an existing list then it works.

Edit 1: Why is the CollectionChanged event null on this ObservableCollection?!?

All datasource are structured as follows.

Databinding:

{Binding Sprints, Source={x:Static ViewModels:CoreViewModel.Instance}}

Property (data source):

private ObservableCollection<SprintEntity> _sprintsField;
public static ObservableCollection<SprintEntity> Sprints
{
  get
  {
    return Instance._sprintsField;
  }
  set
  {
    if (Instance._sprintsField != value)
    {
      Instance._sprintsField = value;
      Instance.RaisePropertyChanged("Sprints");
    }
  }
}

Code to get data (correctly fetches data):

public static void GetSprints(int workspaceID, Action<bool, string> callback)
{
  var proxy = new NotificationServiceClient();
  proxy.GetSprintsCompleted += (sender, e) =>
  {
    if (e.Error == null)
    {
      Sprints = e.Result;
      callback(true, null);
    }
    else
    {
      callback(false, e.Error.Message);
      throw e.Error;
    }
  };
  proxy.GetSprintsAsync(workspaceID);
}
Oliver
  • 35,233
  • 12
  • 66
  • 78
  • See if this makes a difference: Instance._sprintsField = null; Instance.RaisePropertyChanged("Sprints"); Instance._sprintsField = value; Instance.RaisePropertyChanged("Sprints"); – Colin Smith Jan 09 '13 at 13:02
  • Sorry, that made no difference. It is almost as if the binding engine is not detecting the INotifyPropertyChanged event. – Oliver Jan 09 '13 at 13:11
  • For this particular one, can you use the `FastObservableCollection` from here "http://stackoverflow.com/questions/7687000/fast-performing-and-thread-safe-observable-collection/7687108#7687108" and debug through its code if the collection changes are happening? – WPF-it Jan 09 '13 at 13:13
  • I did this: var test = new FastObservableCollection(); Sprints = test; test.AddItems(e.Result); This illustrated something that I found weird! Even before this I noticed that the CollectionChanged even was null!! Why? – Oliver Jan 09 '13 at 13:42
  • A long shot idea....create your own CollectionViewSource which binds to your collection, and then your control binds to the CollectionViewSource....maybe that could make a difference. http://www.zagstudio.com/blog/387#.UO15uIfZbKE – Colin Smith Jan 09 '13 at 14:08
  • Can you send me a small code project that reproduces the problem at netfx45compat at Microsoft dot com? --Varun Gupta from Microsoft .NET Framework Compatibility Team. – Varun Jan 10 '13 at 08:14

0 Answers0