Hi,
If you have a property like "FirstName", which has its own editor "FirstNameEditor" and that depends on another property like "IsMale" :
This is available in v2.4 Plus version of the Toolkit.
If you have a property like "FirstName", which has its own editor "FirstNameEditor" and that depends on another property like "IsMale" :
public bool IsMale { get; set; }
[Editor( typeof( FirstNameEditor ), typeof( FirstNameEditor ) )]
[DependsOn( "IsMale" )]
public string FirstName { get; set; }
Then you can do what you want in the FirstNameEditor...including modifying the type of the editor :public class FirstNameEditor : Xceed.Wpf.Toolkit.PropertyGrid.Editors.ITypeEditor
{
public FrameworkElement ResolveEditor( Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem )
{
if( ( ( Person )propertyItem.Instance ).IsMale )
{
ComboBox comboBox = new ComboBox();
comboBox.Foreground = new SolidColorBrush( Colors.Green );
comboBox.ItemsSource = new List<string>() {"Tom", "Mark", "Bryan"};
comboBox.SelectedIndex = 0;
var _binding = new Binding( "Value" ); //bind to the Value property of the PropertyItem
_binding.Source = propertyItem;
_binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding( comboBox, ComboBox.SelectedItemProperty, _binding );
return comboBox;
}
else
{
TextBox textBox = new TextBox();
textBox.Foreground = new SolidColorBrush( Colors.Blue );
textBox.Text = "TEST";
var _binding = new Binding( "Value" ); //bind to the Value property of the PropertyItem
_binding.Source = propertyItem;
_binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding( textBox, TextBox.TextProperty, _binding );
return textBox;
}
}
}
So yes, the type of the editor can be changed depending on another property;s value.This is available in v2.4 Plus version of the Toolkit.