Checking to make sure my assumptions are correct.
I have an ObservableCollection class. I am calling a web service and retrieving an array of Devices. I am then enumerating the ObservableCollection and setting each item to the corresponding device retrieved from the web service. The devices I rerieved have different property values than the items in the ObservableCollection, but PropertyChanged events are not firing.
I assume that this is ByDesign and that in order to have the PropertyChanged event fire I actually have to enumerate each property and set the value?
For example, in the case below, no PropertyChanged events fire on any of the Device class properties.
ObservableCollection<Device> Items = new ObservableCollection<Device>();
Items = LoadItems();
List<Device> devices = GetDevices();
foreach (var item in Items)
{
var currentDevice = devices.Single(d1 => d1.ID == item.ID);
item = currentDevice;
}
However, if I manually update each property, I'm in business:
ObservableCollection<Device> Items = new ObservableCollection<Device>();
Items = LoadItems();
List<Device> devices = GetDevices();
foreach (var item in Items)
{
var currentDevice = devices.Single(d1 => d1.ID == item.ID);
item.Latitude = currentDevice.Latitude;
item.Longitude= currentDevice.Longitude;
}
In the case above, both Latitude and Longitude fire their events.
Since my class has a bunch of properties is there a better way to do this than one by one?