I've defined an Observable collection as shown below,
public class PropertyFieldsInExcel
{
public string LongNames { get; set; }
public string ShortNames { get; set; }
public string CNames { get; set; }
}
static ObservableCollection<PropertyFieldsInExcel> Properties =
new ObservableCollection<PropertyFieldsInExcel>();
I have a method which changes the the value of some of the elements in that class like so,
public static void AutofillCell()
{
((INotifyPropertyChanged)Properties).PropertyChanged +=
new PropertyChangedEventHandler(PropertyChangedEvent);
Properties[i].CNames = "It works";
Properties[i].CNames = "Ha ha ha";
((INotifyPropertyChanged)Properties).PropertyChanged -=
new PropertyChangedEventHandler(PropertyChangedEvent);
}
When I assign a value to a particular element as shown above, the event does not fire. Why? What is the mistake I've committed?
The code of the event handler is like so,
private static void PropertyChangedEvent(object sender, PropertyChangedEventArgs e)
{
//Some code to be executed
}