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

New Post: PropertyGrid + Custom Editors + ClassLibrary

$
0
0
You are right, it's works for simple property. See my second path in this post about refresh ExpandableObject.
public class SubClass: INotifyPropertyChanged
{
  public string FirstName { get {...}; set {...; OnPropertyChanged("FirstName")}; }
  public string LastName { get {...}; set {...; OnPropertyChanged("LastName")}; }
}

public class MyClass: INotifyPropertyChanged
{
  [ExpandableObject]
  [Editor(typeof(NameEditor), typeof(NameEditor))] // for refresh this value in PropertyGrid
  public SubClass Name { get; set; }
}

// this not used PG for my property
public class NameEditor: Xceed.Wpf.Toolkit.PropertyGrid.Editors.ITypeEditor
{
        public FrameworkElement ResolveEditor(Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem)
        {
            TextBlock textBlock = new TextBlock();
            var binding = new Binding("Value.FirstName");
            binding.Source = propertyItem;
            binding.ValidatesOnExceptions = true;
            binding.ValidatesOnDataErrors = true;
            binding.Mode = BindingMode.OneWay;
            BindingOperations.SetBinding(textBlock, TextBlock.TextProperty, binding);
            return textBlock;
        }
}

Viewing all articles
Browse latest Browse all 4964

Trending Articles



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