public Result.IfSuccess <BindingSource> VisitDataContextSource(DataContextSource dataContextSource, Parameters parameters, Context context) { var binding = parameters.Binding; var elementName = context.XamlElementNameProvider.GetName(binding); context.BindingPathBuilder.AppendLine( $@" {context.BindingSource.Name}.BindSourceDataContextOneWay( {binding.Id}, {TargetCodeGenerator.GetTarget(this.elementType, elementName, parameters.HasCodeBehind)}, {this.targetValue.GetDependencyProperty()}, t => {this.targetValue.GetPropertyGetter()});"); context.ExternAliases.TryAdd(this.elementType); return(Result.Success(context.BindingSource)); }
public bool ElementBindingSource( ElementBindingSourceNode elementBindingSourceNode, Parameters parameters, Context context) { var elementName = context.XamlElementNameProvider.GetName(elementBindingSourceNode); var elementType = parameters.XamlTypeResolver.Parse(elementBindingSourceNode.TargetElement.Name); var bindingSource = context.BindingSourceProvider.AddElement(elementType, elementName); var sourceVariableName = bindingSource.Name; var newContext = new Context(new StringBuilder(), bindingSource, context); if (this.VisitChildBindings(elementBindingSourceNode.Bindings, parameters, newContext)) { context.ExternAliases.TryAdd(elementType); context.BindingContainerSourceCodeBuilder.AppendLine($" var {sourceVariableName} = this.GetElementContext({TargetCodeGenerator.GetTargetLambda(elementType, elementName, context.HasCodeBehind)});"); context.BindingContainerSourceCodeBuilder.Append(newContext.BindingContainerSourceCodeBuilder); return(true); } return(false); }