internal BindingExpression(Binding binding, DependencyObject target, DependencyProperty property) { ParentBinding = binding; Target = target; Property = property; //setting _isDataContextBound to true if none of the following elements are set in the parentBinding: ElementName, Source and RelativeSource : _isDataContextBound = binding.ElementName == null && binding.Source == null && binding.RelativeSource == null; //we change the Binding so that when it is bound to the DataContext, we handle it the same way as if (_isDataContextBound) { ParentBinding.INTERNAL_ComputedSource = target; string str = ParentBinding.Path.Path; if (!String.IsNullOrWhiteSpace(str) && !((str = str.Trim()) == ".")) { ParentBinding.INTERNAL_ComputedPath = new PropertyPath("DataContext." + str); } else { ParentBinding.INTERNAL_ComputedPath = new PropertyPath("DataContext"); } _isDataContextBound = false; //test to see if the problems with the DataContext are still there or not. } string path = (binding.INTERNAL_ComputedPath != null ? binding.INTERNAL_ComputedPath.Path : null); var walker = PropertyPathWalker = new PropertyPathWalker(path, _isDataContextBound); if (binding.Mode != BindingMode.OneTime) { walker.Listen(this); } }
internal BindingExpression(Binding binding, DependencyProperty property) { ParentBinding = binding; TargetProperty = property; if (binding.ElementName == null && binding.Source == null && binding.RelativeSource == null) //this means that it is bound to current DataContext. { this.isDataContextBound = true; //we change the Binding so that when it is bound to the DataContext, we handle it the same way as string str = ParentBinding.Path.Path; if (!string.IsNullOrWhiteSpace(str) && !((str = str.Trim()) == ".")) { this.computedPath = "DataContext." + str; } else { this.computedPath = "DataContext"; } } else { this.computedPath = this.ParentBinding.Path != null ? this.ParentBinding.Path.Path : string.Empty; } //string path = (binding.INTERNAL_ComputedPath != null ? binding.INTERNAL_ComputedPath.Path : null); var walker = propertyPathWalker = new PropertyPathWalker(this.computedPath, false); if (binding.Mode != BindingMode.OneTime) { walker.Listen(this); } }
internal BindingExpression(Binding binding, DependencyProperty property) { ParentBinding = binding; TargetProperty = property; bool isDataContextBound = binding.ElementName == null && binding.Source == null && binding.RelativeSource == null; string path = ParentBinding.XamlPath ?? ParentBinding.Path.Path ?? string.Empty; var walker = _propertyPathWalker = new PropertyPathWalker(path, isDataContextBound); if (binding.Mode != BindingMode.OneTime) { walker.Listen(this); } }
private void UpdateDataType() { if (this.Column != null && this.Column.DataType == typeOfObject) { using (PropertyPathWalker propertyPathWalker = new PropertyPathWalker(this.Column.Binding.Path.Path, true)) { propertyPathWalker.Update(this.DataContext); if (!propertyPathWalker.IsPathBroken) { this.Column.DataType = propertyPathWalker.FinalNode.ValueType; } } } }