I’ve been working on checking a value in an Infragistics DataProvider Field and if it’s a specific value, change it.
<igDP:Field Name="BeginDate" Label="Begin Date">
<igDP:Field.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamDateTimeEditor}">
<Style.Triggers>
<DataTrigger Binding="{Binding BeginDate}" Value="01/01/0001">
<Setter Property="Text" Value=" "/>
</DataTrigger>
</Style.Triggers>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
The BeginDate value is of type DateTime. I am trying to check it for being DateTime’s min value and, if so, I simply want the field to display a blank.
I have tried XamDateTimeEditor as well as XamTextEditor. With DateTimeEditor, nothing happens. With TextEditor, all values are blanked out.
Would appreciate a nudge in the right direction!
You can do this by changing the Template of the editor to be empty when the value is the minimum value for a DateTime. There are a few changes needed to accomplish this.
Change #1, in the style provided the binding is to BeginDate and this binding is invalid because the DataContext is the DataRecord and not the item from the list that you are binding to. If you check the output window you will see errors like the following:
System.Windows.Data Error: 40 : BindingExpression path error: ‘BeginDate’ property not found on ‘object’ ”DataRecord’ (HashCode=13078478)’. BindingExpression:Path=BeginDate; DataItem=’DataRecord’ (HashCode=13078478); target element is ‘XamDateTimeEditor’ (Name=”); target property is ‘NoTarget’ (type ‘Object’)
To resolve this, change the binding to be “DataItem.BeginDate” rather than “BeginDate”.
Change #2, modify the Setter to set the Template rather than the Text and set it to an empty ConrolTemplate.
The updated Field definition will be:
This solution will still allow you to edit values if editing is enabled for this field in your grid.