Posted 15 years ago
by SledgeHammer01
Version: 10.1.0521
Platform: .NET 4.0
Environment: Windows XP (32-bit)
Hi,
I am using a date picker in a property grid. I have noticed that if I throw an exception in the setter, the error template is not shown. You can easily see this in your sample (/ProductSamples/PropertyGridSamples/QuickStart/PropertyEditors/).
1) select DateTimePicker (date only)
2) enter "aaa"
3) field becomes null and you pass a null to the property setter
property grid does not show the red rectangle in this case.
As far as my code goes:
the property...the DatePropertyEditor class...
the DatePropertyEditor template...
[Modified at 04/23/2010 12:02 PM]
[Modified at 04/23/2010 12:03 PM]
I am using a date picker in a property grid. I have noticed that if I throw an exception in the setter, the error template is not shown. You can easily see this in your sample (/ProductSamples/PropertyGridSamples/QuickStart/PropertyEditors/).
1) select DateTimePicker (date only)
2) enter "aaa"
3) field becomes null and you pass a null to the property setter
property grid does not show the red rectangle in this case.
As far as my code goes:
the property...
[Editor(typeof(DatePropertyEditor), typeof(PropertyEditor))]
public object FieldMinDT
{
get
{
return FieldMin;
}
set
{
if (value == null) throw new Exception("test");
FieldMin = value;
}
}
public class DatePropertyEditor : PropertyEditor
{
#region Constructors
public DatePropertyEditor()
{
}
#endregion
#region Overrides
public override DataTemplate ValueTemplate
{
get;
set;
}
public override object ValueTemplateKey
{
get
{
return "DatePropertyEditor";
}
}
public override DataTemplateSelector ValueTemplateSelector
{
get;
set;
}
#endregion
}
<DataTemplate x:Key="DatePropertyEditor">
<shared:DateTimePicker Margin="0" IsEditable="True" BorderThickness="0" Value="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}, Mode=TwoWay}"
ValueConverterParameter="{x:Static shared:DateTimeToStringPattern.ShortDate}" />
</DataTemplate>
[Modified at 04/23/2010 12:03 PM]