private bool ConnectToPropertyInSource(bool isSourceCollectionViewCurrentItem) { if (this.source == null || this.source == DependencyProperty.UnsetValue) { return(false); } var sourceType = this.source.GetType(); if (this.propertyListener == null || this.propertyListener.SourceType != sourceType) { this.propertyListener = null; var dependencyObject = this.source as DependencyObject; if (dependencyObject != null) { var dependencyProperty = this.property ?? DependencyProperty.GetRegisteredDependencyProperty(dependencyObject, this.propertyName); if (dependencyProperty != null) { this.propertyListener = new DependencyPropertyListener(this, sourceType, dependencyProperty, this.listenToChanges); } } if (this.propertyListener == null && this.propertyName != null) { var property = sourceType.GetProperty(this.propertyName); if (property != null) { this.propertyListener = new CLRPropertyListener(this, sourceType, property, this.listenToChanges); } } } if (this.propertyListener == null) { if (!isSourceCollectionViewCurrentItem) { var collectionViews = this.source as ICollectionView; if (collectionViews != null) { this.source = collectionViews.CurrentItem; this.collectionView = collectionViews; this.collectionView.CurrentChanged += this.CurrentItemChanged; return(this.ConnectToPropertyInSource(true)); } } } else { this.propertyListener.Source = this.source; try { object value = this.propertyListener.Value; } catch (Exception e) { Debug.WriteLine(e); if (e is OutOfMemoryException || e is StackOverflowException || e is AccessViolationException || e is ThreadAbortException) { throw; } this.Disconnect(); } } return(this.propertyListener != null); }