示例#1
0
        private static BindablePropertyInfo GetBindableProperty(Type viewModelType, string elementName)
        {
            var cleanName = elementName.Trim('_');

            if (string.IsNullOrEmpty(cleanName))
            {
                return(null);
            }

            // Split path in parts
            IList <string> nameParts = cleanName.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);

            string currentPath = null;
            BindablePropertyInfo bindableProperty = null;

            foreach (var namePart in nameParts)
            {
                bindableProperty = GetBindableProperty(viewModelType, namePart, currentPath);
                if (bindableProperty == null)
                {
                    return(null);
                }

                viewModelType = bindableProperty.Property.PropertyType;
                currentPath   = bindableProperty.Path;
            }

            return(bindableProperty);
        }
 public static bool Bind(this ElementConvention elementConvention, BindablePropertyInfo propertyInfo, FrameworkElement element)
 {
     return elementConvention.ApplyBinding(propertyInfo.Property.PropertyType, propertyInfo.Path, propertyInfo.Property, element, elementConvention);
 }
 public static bool Bind(this ElementConvention elementConvention, BindablePropertyInfo propertyInfo, FrameworkElement element)
 {
     return(elementConvention.ApplyBinding(propertyInfo.Property.PropertyType, propertyInfo.Path, propertyInfo.Property, element, elementConvention));
 }