In a WPF application, I need to refresh the UI for all components at a specific time interval. I would need to know what is the simplest way.
My question: How to rise OnPropertyChanged?
Do you know a better approch?
Please provide a sample of code if possible thanks
namespace MyClient.Common
{
public abstract class BindableBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected bool SetProperty<T>(ref T storage, T value, /*[CallerMemberName]*/ String propertyName = null)
{
if (object.Equals(storage, value)) return false;
storage = value;
this.OnPropertyChanged(propertyName);
return true;
}
protected void OnPropertyChanged(/*[CallerMemberName]*/ string propertyName = null)
{
var eventHandler = this.PropertyChanged;
if (eventHandler != null)
{
eventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}