I\'m trying to bind a static property of some class to some control. I\'ve tryied a few implementation but each has its problem:
All examples use the next XAML:
public static String StatusInformation
{
get { return _StatusInformation; }
set { _StatusInformation = value; OnStaticPropertyChanged("StatusText"); }
}
#region Handlig Static Properties Changed
private static System.ComponentModel.PropertyChangedEventHandler staticpropChanged;
static protected void OnStaticPropertyChanged(string pname)
{
System.ComponentModel.PropertyChangedEventArgs e = new System.ComponentModel.PropertyChangedEventArgs(pname);
System.ComponentModel.PropertyChangedEventHandler h = staticpropChanged;
if (h != null)
h(null, e);
}
private void Handler_PropertyChange(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
NotifyPropertyChanged(e.PropertyName);
}
#endregion
public string StatusText
{
get { return ExchangeServices.StatusInformation; }
set { ExchangeServices.StatusInformation = value; }
}
this way i didnt have to do any handling in the event at all. this was really helpfull to create one status bar for my entire program and update it from anywhere and any user control in my ever expanding program.
Thank you to shimpossible