Hi,
I have an existing UnboundField that is bound to a DateTime and I only want to display the date portion, so I set the EditoryStyle of the Field and set the Mask and Format like the following:
<igDP:UnboundField Name="Date" Label="Date" BindingPath="StartDateTime"> <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamDateTimeEditor}"> <Style.Setters> <Setter Property="Mask" Value="{}{date}" /> <Setter Property="Format" Value="{x:Static scsc:DateFormats.DateFormat}" /> </Style.Setters> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings></igDP:UnboundField>
But when I migrate the code to use Infragistics 14.2, and follow the recommendation to change UnboundField to Field with AlternateBinding, the field doesn't show the data any more. If I remove the EditorStyle, then the whole date time shows up, so I know the AlternateBinding is correct. If I change the field to use NameBinding, then the EditorStyle will work. Here's the updated code using AlternateBinding:
<igDP:Field Name="Date" Label="Date" BindingType="UseAlternateBinding" AlternateBinding="{Binding StartDateTime}"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamDateTimeEditor}"> <Style.Setters> <Setter Property="Mask" Value="{}{date}" /> <Setter Property="Format" Value="{x:Static scsc:DateFormats.DateFormat}" /> </Style.Setters> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:Field>
Can you tell me what I did wrong?
As I side note, I need to bind the same DateTime to two separate Fields, one showing just the date portion, and another showing just the time portion. Because Field.Name needs to be unique, I have to use UnboundField (or Field with AlternateBinding).
Thanks for any help!
Harold
Hello Harold,
Thank you for your post.
I have been looking into it and the code snippet that you have provided. I created a sample application based on your scenario and I could not managed to reproduce the behavior that you have described. If you are not able to reproduce the issue with the attached sample application, would you please modify it with the functionality, that you are using, so it reproduces the issue. This way I would be able to further investigate this for you and provide you with more detailed information on this matter.
Looking forward to hearing from you.
Hi Zhivko,
Thanks for the quick response and the sample code. I gave wrong information in my original post. We are binding to a nullable DateTimeOffset, not DateTime. If you change the sample code to use DateTimeOffset or DateTimeOffset?, then the data doesn't show up.
Thanks,
I have been investigating your issue. It seems that the issue comes from the inability of the XamDateTimeEditor to edit DateTimeOffset values. If you want you can use its DateTime property to pass it to a xamDateTimeEditor. I modified my previous sample application to show you how you can achieve this.
Also I can suggest to take a look at the following forum thread http://ko.infragistics.com/community/forums/t/63091.aspx , where a similar issue was discussed.
Please let me know if you need any further assistance on this matter.
But this used to work when the field is an UnboundField. I've updated your sample to show it works when UnboundField is used. I also made the grid read-only because that's what I have.
I have been looking into it and the sample application that you have provided. The behavior that you described is expected. In the last sample that you have send it works, because the unbound fields treated the cell`s value as string. You can see this by setting the AllowEdit to true and AutoGenerateFields to true, the result that you can see is that the DateTimeOffset is treated as string not as DateTime. What I can suggest is to use the XamMaskedEditor instead of XamDateTimeEditor. If you would like to use it you should use its DateTime property to pass it to a XamDateTimeEditor. I modified my previous sample application to show you how you can achieve this your requirements with XamMaskedEditor. I set the Mask property for date and time and the format property.
Thanks Zhivko! I'll try your suggestions.
Thank you for your feedback.
If you require any further assistance please do not hesitance to ask.