public FrameworkElement ResolveEditor(Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem) { Contract.Requires(propertyItem != null); Grid grd = new Grid(); var cd1 = new ColumnDefinition(); cd1.Width = new GridLength(1, GridUnitType.Star); var cd2 = new ColumnDefinition(); cd2.Width = new GridLength(1, GridUnitType.Auto); grd.ColumnDefinitions.Add(cd1); grd.ColumnDefinitions.Add(cd2); textBox = new PropertyGridEditorTextBox(); textBox.Watermark = "Select file"; 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(textBox, PropertyGridEditorTextBox.TextProperty, _binding); Button b = new Button(); b.Content = "..."; b.Click += B_Click; Grid.SetColumn(textBox, 0); Grid.SetColumn(b, 1); grd.Children.Add(textBox); grd.Children.Add(b); return(grd); }
public FrameworkElement ResolveEditor(PropertyItem propertyItem) { TextBox textBox = new PropertyGridEditorTextBox(); var binding = new Binding(nameof(PropertyItem.Value)); binding.Converter = new Point2DValueConverter(); BindingOperations.SetBinding(textBox, TextBox.TextProperty, binding); return(textBox); }