protected override object Evaluate()
        {
            Tuple <object, string> o = this.RewritePath(this.ParentBinding.Path);

            this.chain = this.pathParser.Parse(o.Item1, o.Item2).ToArray();

            if (this.chain != null)
            {
                this.AttachListeners();

                PropertyPathToken last = this.chain.Last();

                if (last.Type == PropertyPathTokenType.FinalValue)
                {
                    return(last.Object);
                }
                else
                {
                    return(DependencyProperty.UnsetValue);
                }
            }
            else
            {
                return(null);
            }
        }
        private void PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            PropertyPathToken link = this.FindLinkInChain(sender);

            if (e.PropertyName == link.PropertyName)
            {
                this.DetachListeners();
                this.Invalidate();
            }
        }
        private void DetachListener(PropertyPathToken link)
        {
            IObservableDependencyObject dependencyObject = link.Object as IObservableDependencyObject;
            INotifyPropertyChanged      inpc             = link.Object as INotifyPropertyChanged;

            if (dependencyObject != null)
            {
                dependencyObject.RemovePropertyChangedHandler(link.PropertyName, this.DependencyPropertyChanged);
            }
            else if (inpc != null)
            {
                inpc.PropertyChanged -= this.PropertyChanged;
            }
        }
        private void DetachListener(PropertyPathToken link)
        {
            IObservableDependencyObject dependencyObject = link.Object as IObservableDependencyObject;
            INotifyPropertyChanged inpc = link.Object as INotifyPropertyChanged;

            if (dependencyObject != null)
            {
                dependencyObject.RemovePropertyChangedHandler(link.PropertyName, this.DependencyPropertyChanged);
            }
            else if (inpc != null)
            {
                inpc.PropertyChanged -= this.PropertyChanged;
            }
        }