Ok Thanks for the comments and suggestions I've revised my question to more accurately reflect what I need.
I'm reading up on how INotifyPropertyChanged works in WPF so that I can implement a sort of bastardization of it in another technology where my UI gets notified any time a property I am tracking on the UI changes (Unity 4.6).
Basically what I need is from how the XAML manages data binding and events for INotifyPropertyChanged when Properties in the code are changed
I have a Unity Project where I need to know how I should have my UI class setup to subscribe to events that tell the UI there has been a change to a property displayed on the UI, and to make all instances where there is Text on the UI associated with that property to update. I need to have the events subscribed to at Run Time because when I am subscribing to them at compile time I am getting Null Reference Exceptions from objects that are null at the time when I have properties displayed on the screen when that object is not null. I.e a class MyObject with a property Property1 where I want to display
var MyGameObject1 = new MyObject();
MyGameObject1.Property1 = "Bob";
where in my setter I have
public string Property1
{
get
{
return _property1;
}
set
{
_property1 = value;
NotifyPropertyChanged("Property1");
}
}
public event EventHandler<UnityPropertyChangedEventArgs> PropertyChanged;
private void NotifyPropertyChanged(string propertyChanged)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new UnityPropertyChangedEventArgs(propertyChanged));
}
}
How can I get my UI to manage at runtime the UI elements I am displaying via text and receive events fired from their setters any time their value changes.