What is the easiest way to fire a callback/handler function when a list of strings changes but also when it's re-bound.
I tried switching from List to ObservableCollection and using CollectionChanged it does work on Add/Remove, but I also need it to work like this when I re-bind the list using "= new".
static class GlobalProperties
{
private static ObservableCollection<string> _mylist = new ObservableCollection<string>();
public static ObservableCollection<string> MyList
{
get
{
return _mylist ;
}
set
{
_mylist = value;
}
}
}
class Program
{
static void Main(string[] args)
{
Globals.MyList.CollectionChanged += HandleChange;
}
public static void HandleChange(object sender, NotifyCollectionChangedEventArgs e)
{
Console.WriteLine("test");
}
}
I need to be able to attach a handler/callback function to - also when setting the property, and not just when adding or removing. This needs to be possible from the main function of the console application.