I have a record Pitch (see below)
[TypeConverter(typeof(PitchTypeConverter))]
public sealed record Pitch(double MinValue, double MaxValue) : IParsable<Pitch>
{
public static readonly Pitch Empty = new(0, 0);
public static Pitch Parse(string s, IFormatProvider provider)
=> throw new NotImplementedException();
public static bool TryParse([NotNullWhen(true)] string s, IFormatProvider provider, [MaybeNullWhen(false)] out Pitch result)
=> throw new NotImplementedException();
public override string ToString()
=> $"{MinValue}-{MaxValue}";
}
As you can see , I also have a TypeConverter (currently not fully implemented, but to show the problem it is sufficient).
public sealed class PitchTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
=> base.CanConvertFrom(context, sourceType);
public override bool CanConvertTo(ITypeDescriptorContext context, [NotNullWhen(true)] Type destinationType)
=> destinationType == typeof(string);
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
=> base.ConvertFrom(context, culture, value);
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
=> value?.ToString() ?? Pitch.Empty.ToString();
public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
=> base.CreateInstance(context, propertyValues);
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
=> base.GetCreateInstanceSupported(context);
public override bool IsValid(ITypeDescriptorContext context, object value)
=> base.IsValid(context, value);
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
=> base.GetProperties(context, value, attributes);
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
=> base.GetPropertiesSupported(context);
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
=> base.GetStandardValues(context);
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
=> base.GetStandardValuesExclusive(context);
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
=> base.GetStandardValuesSupported(context);
}
The Pitch lives inside a ViewModel and is correctly displayed in the RadPropertyGrid, so in that sense everthing works fine.
[Category("Conditions")]
[Description("Sets the minimum/maximum allowed pitch limit.")]
public Pitch PitchLimit
{
get => GetProperty(Pitch.Empty);
set => SetProperty(value);
}
[Category("Conditions")]
public bool RequiresDE
{
get => GetProperty<bool>();
set => SetProperty(value);
}
when I now edit values in the RadPropertyGrid, the RequiresDE works when pressing enter or selecting the checkbox. It doesn't work however when I edit the value for the Pitch property. I can see that the SetProperty for RequiresDE is called, but when editing the PitchLimit the SetProperty is not called.
I honestly out of ideas to find out why the RequiresDE is called and the PitchLimit isn't.
Any help is appreciated.
Thanks