The customer editor code is as follows:
public class DefaultUomEditor : ITypeEditor
{
private TextBox _tb;
public DefaultUomEditor()
{
_tb = new TextBox();
}
public System.Windows.FrameworkElement ResolveEditor(Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem)
{
propertyItem.IsReadOnly = true;
//create the binding from the bound property item to the editor
var _binding = new Binding("Value"); //bind to the Value property of the PropertyItem
_binding.Source = propertyItem;
_binding.ValidatesOnExceptions = true;
_binding.ValidatesOnDataErrors = true;
_binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding(_tb, TextBox.TextProperty, _binding);
if (propertyItem.Instance != null)
{
// do something...
}
return _tb;
}
}
And the PropertyGrid.SelectedObject is bound to an object instance which has the following property defined as: [DisplayName("Default UOM")]
[Editor(typeof(DefaultUomEditor), typeof(DefaultUomEditor))]
public string Uom
{
get { return this._uom; }
internal set
{
this._uom = value;
RaisePropertyChanged(() => this.Uom);
}
}