Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
Field Format for Non 24h Time Format
posted

Hello,

I've got a problem with the datagrid field format property. I want to display the time in non 24h format like "02:35:56 AM". I set the format to "hh:mm:ss tt" but this does not work. Did i make any mistake?

XAML:

<Custom:XamDataGrid DataSource="{Binding Data}">
<Custom:XamDataGrid.FieldLayouts>
<Custom:FieldLayout>
<Custom:Field Format="hh:mm:ss tt"
Label="Zeit"
IsReadOnly="True"
AlternateBinding="{Binding Date}">

</Custom:Field >
</Custom:FieldLayout>
</Custom:XamDataGrid.FieldLayouts>
</Custom:XamDataGrid>

I added a test solution...

Thanks

Andreas

WpfApplication1.zip
Parents
  • 6365
    Offline posted

    Hello Andreas,

    Thank you for the sample application you have provided.

    I tested the application and the XamDataGrid seems to display the Date property for every DataItem in a 12 hour format correctly. I have attached an image that shows how the data in code-behind is in a 24 hour format and the XamDataGrid displays it in a 12 hour format.

    24h format: Format="HH:mm:ss tt"
    12h format: Format="hh:mm:ss tt"

    Are you noticing a behavior that is different from the one I have mentioned above? If so, can you please provide more details on the issue?

    Please note that in the case of the application you have provided, it is unnecessary to use an AlternateBinding since the DateTime instance is placed directly in the DataItem class and we can use a simple name binding which could provid a better performance.

    <Custom:Field Format="hh:mm:ss tt" 
                    Label="Zeit"
                    IsReadOnly="True"
                    Name="Date">

    In addition, you can use the DateTimeField for displaying DateTime data. In this case the XamDataGrid will automatically set the necessary settings for displaying the data and additional DateTime settings will be available.

    <Custom:DateTimeField ... >
    </Custom:DateTimeField>

    If you have any questions, please let me know.

Reply Children