示例#1
0
        public override ValidationResult Validate(object value, CultureInfo culture)
        {
            SourceDataConverter converter = new SourceDataConverter(m_sourceSupportDBNull);

            Exception exception;

            converter.TryConvertBack(value, m_targetType, CultureInfo.InvariantCulture, culture, out exception);

            if (exception != null)
            {
                return(new ValidationResult(false, exception.Message));
            }

            return(ValidationResult.ValidResult);
        }
        internal IValueConverter GetBindingConverter(object sourceItem)
        {
            if (!this.IsSealed)
            {
                throw new InvalidOperationException("An attempt was made to apply a binding to a DataGridItemProperty that has not be added to the ItemProperties collection.");
            }

            if (m_bindingConverter == null)
            {
                if (m_converter != null)
                {
                    m_bindingConverter = m_converter;
                }
                else
                {
                    m_bindingConverter = new SourceDataConverter(ItemsSourceHelper.IsItemSupportingDBNull(sourceItem), CultureInfo.InvariantCulture);
                }
            }

            return(m_bindingConverter);
        }