public BindingExpression(Binding binding, MemberInfo targetProperty, object target)
{
if (binding == null)
throw new ArgumentNullException("binding");
if (targetProperty == null)
throw new ArgumentNullException("targetProperty");
if (target == null)
throw new ArgumentNullException("target");
Binding = binding;
Binding.Target = target;
TargetProperty = targetProperty;
if(string.IsNullOrEmpty(binding.TargetPath))
{
binding.TargetPath = targetProperty.Name;
}
object viewSource = Binding.Source;
_ViewProperty = viewSource.GetType().GetNestedMember(ref viewSource, Binding.SourcePath, true);
Binding.ViewSource = viewSource;
SourceProperty = _ViewProperty;
var dataContext = viewSource as IDataContext;
if (dataContext != null && dataContext.DataContext != null)
{
var source = dataContext.DataContext;
SourceProperty = source.GetType().GetNestedMember(ref source, Binding.SourcePath, true);
Binding.Source = source;
}
}