using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
public static class INotifyPropertyChangedExtensions
{
///
/// Creates a property binding.
///
/// The target.
/// Name of the target property.
/// The source.
/// Name of the source property.
public static void Bind(this INotifyPropertyChanged target, String targetPropName, INotifyPropertyChanged source, String sourcePropName)
{
PropertyInfo targetPropInfo = target.GetType().GetProperty(targetPropName);
PropertyInfo sourcePropInfo = source.GetType().GetProperty(sourcePropName);
source.PropertyChanged += (x, e) =>
{
if (e.PropertyName == sourcePropName)
{
targetPropInfo.SetValue(target, sourcePropInfo.GetValue(source));
}
};
}
}