示例#1
0
        internal static PropertyItem CreatePropertyItem(PropertyDescriptor property, object instance, PropertyGrid grid, string bindingPath)
        {
            PropertyItem propertyItem = new PropertyItem(instance, property, grid, bindingPath);

            var binding = new Binding(bindingPath)
            {
                Source = instance,
                ValidatesOnExceptions = true,
                ValidatesOnDataErrors = true,
                Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay
            };

            propertyItem.SetBinding(PropertyItem.ValueProperty, binding);

            propertyItem.Editor = PropertyGridUtilities.GetTypeEditor(propertyItem, grid.EditorDefinitions);

            return(propertyItem);
        }