示例#1
0
        public Binding(FieldBindingBaseAttribute attribute, int level)
        {
            Path        = attribute.Path;
            BindingMode = attribute.BindingMode;

            if (attribute is IConstAttribute constAttribute && Path == null)
            {
                IsConst     = true;
                _constValue = constAttribute.GetConstValue();
            }

            if (attribute.ConverterType != null)
            {
                ValueConverter = Activator.CreateInstance(attribute.ConverterType) as IValueConverter;

                if (ValueConverter == null)
                {
                    var message = $"{attribute.ConverterType} does not implement IValueConverter.";
                    throw new InvalidOperationException(message);
                }

                ConverterParameter = attribute.ConverterParameter;
            }

            RelativeSourceMode = attribute.RelativeSourceMode;

            Level = level;

            SupportsDeferredEvaluation = attribute.SupportsDeferredBinding;
        }
示例#2
0
 private Binding GetBinding(FieldBindingBaseAttribute attribute)
 {
     return(new Binding(attribute, GetBindingLevel(attribute.Binding)));
 }