コード例 #1
0
        internal static DependencyProperty ResolveProperty(Type type, DependencyProperty property)
        {
            var resolvedProperty = property;

            var propertyName = DependencyPropertyProxyManager.GetPropertyName(property, type);

            if (propertyName != null)
            {
                resolvedProperty = DependencyPropertyManager.GetDependencyProperty(propertyName, type);
            }

            return(resolvedProperty);
        }
コード例 #2
0
        public static DependencyProperty ResolveAttachedDependencyProperty(string property, IServiceProvider serviceProvider)
        {
            var typeResolver = (IXamlTypeResolver)serviceProvider?.GetService(typeof(IXamlTypeResolver));

            if (typeResolver == null)
            {
                return(null);
            }

            var dotIndex = property.IndexOf(".", StringComparison.Ordinal);

            if (dotIndex == -1)
            {
                return(null);
            }

            var startIndex = AdvancePosition(property, 0, 1);

            if (startIndex == -1)
            {
                return(null);
            }

            var typeName = property.Substring(startIndex, dotIndex - startIndex);
            var type     = typeResolver.Resolve(typeName);

            if (type == null)
            {
                return(null);
            }

            dotIndex = AdvancePosition(property, dotIndex + 1, 1);

            if (dotIndex == -1)
            {
                return(null);
            }

            var endIndex = AdvancePosition(property, property.Length - 1, -1);

            if (endIndex == -1 || endIndex <= dotIndex)
            {
                return(null);
            }

            return(DependencyPropertyManager.GetDependencyProperty(property.Substring(dotIndex, endIndex - dotIndex + 1), type));
        }