Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: File Browser from Property Grid

$
0
0
Hi,

If you have the Toolkit Plus version, and your Property is of type "FileInfo", you will automatically have a FilePicker editor (with a browsing button).

If you decide to use an attribute Editor, it has to be an ITypeEditor, which System.Windows.Forms.Design.FileNameEditor is not.
The ITypeEditor will implement a ResolveEditor() method to display and use the editor you want. Here's an example :
 public class MyEditor: ITypeEditor
  {
    public FrameworkElement ResolveEditor( Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem )
    {
      var textBox = new TextBox();
      textBox.Background = new SolidColorBrush( Colors.Red );

      //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( textBox, TextBox.TextProperty, _binding );
      return textBox;
    }
  }

Viewing all articles
Browse latest Browse all 2157

Trending Articles



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