For a xamDataGrid, I currently have AutoGenerateFields = False and for the field ProcessDate I am using:
<igDP:FieldSettings EditorStyle="{StaticResource ResourceKey=DateStyle}" >igDP:FieldSettings>
The style DateStyle is defined in a Resource file that is referenced in ResourceDictionary section of the xamDataGrid:
<ResourceDictionary Source="../Resource/ResourceTextStyles.xaml" />
In the above resource file, I have:
<Style x:Key="DateStyle" TargetType="{x:Type igEditors:XamTextEditor}">
<Style.Setters>
<Setter Property="Format" Value="MMM-dd-yyyy"/>
Style.Setters>
Style>
Now, I want to have AutoGenerateFields = True. I want to say - if a column name = "ProcessDate", format the data in the field as MMM-dd-yyyy. and have this in a resource file which is referenced in the xaml - How do I do this?
The following is not working:
<Style TargetType="{x:Type igEditors:XamTextEditor}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Field.Name, RelativeSource={RelativeSource Self}}" Value="ProcessDate">
DataTrigger>
Style.Triggers>
Anyone??? Just looking for way to put column formats in a resource file. I have several xamDataGrids in my app and I want all field formats to be in a resource file.
Hello Jay,
I have been looking into your issue. When the Fields of the XamDataGrid are autogenerated, the editor of every field is set according to the type of the data ina that field. For example is you have a DateTime property, that editor for the field, displaying the DateTime property would be XamDateTimeEditor.
Having this in mind I can suggest creating a style for the XamDateTimeEditor instead of the XamTextEditor. Then you can bind to the fields of the XamDataGrid or you can bind to the CellValuePresenter of the Field.
Here is an example of the style for the XamDateTimeEditor, with binding to the CellValuePresenter, that you can use:
<Style TargetType="{x:Type igEditors:XamDateTimeEditor}">
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Record.Cells[0].Field.Name}" Value="Date" >
</DataTrigger>
</Style.Triggers>
</Style>
Please do not hesitate to let me know if you have any further questions on this matter.
I am just checking if you have any further questions on this matter. Please do not hesitate to let me know if you do.