Exemple #1
0
        /// <summary>
        /// Determines the interesting dependency properties.
        /// </summary>
        /// <returns>A list of names with dependency properties to subscribe to.</returns>
        private List <DependencyPropertyInfo> DetermineInterestingDependencyProperties()
        {
            var targetControlType = TargetControlType;

            return(_dependencyPropertiesToSubscribe.GetFromCacheOrFetch(targetControlType, () =>
            {
                var controlDependencyProperties = TargetControl.GetDependencyProperties();
                var dependencyProperties = new List <DependencyPropertyInfo>();

                if ((_dependencyPropertySelector == null) || (_dependencyPropertySelector.MustSubscribeToAllDependencyProperties(targetControlType)))
                {
                    dependencyProperties.AddRange(controlDependencyProperties);
                }
                else
                {
                    var dependencyPropertiesToSubscribe = _dependencyPropertySelector.GetDependencyPropertiesToSubscribeTo(targetControlType);
                    if (!dependencyPropertiesToSubscribe.Contains("DataContext"))
                    {
                        dependencyPropertiesToSubscribe.Add("DataContext");
                    }

                    foreach (var gatheredDependencyProperty in controlDependencyProperties)
                    {
                        if (dependencyPropertiesToSubscribe.Contains(gatheredDependencyProperty.PropertyName))
                        {
                            dependencyProperties.Add(gatheredDependencyProperty);
                        }
                    }
                }

                return dependencyProperties;
            }));
        }