Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: PropertyGrid with object implementing ICustomTypeConverter to add extra properties

$
0
0
My fix for this was to add the following code to DescriptorPropertyDefinition:
        public object GetValueInstance(object sourceObject)
        {
            ICustomTypeDescriptor customTypeDescriptor = sourceObject as ICustomTypeDescriptor;
            if (customTypeDescriptor != null)
                sourceObject = customTypeDescriptor.GetPropertyOwner(PropertyDescriptor);

            return sourceObject;
        }
Then I updated the CreateBinding() method to be:
        protected override BindingBase CreateValueBinding()
        {
            //Bind the value property with the source object.
            var binding = new Binding(PropertyDescriptor.Name)
            {
                Source = GetValueInstance(SelectedObject),
                Mode = PropertyDescriptor.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay,
                ValidatesOnDataErrors = true,
                ValidatesOnExceptions = true
            };

            return binding;
        }

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>