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
560
Localization of MaskEditor - Time value in 24 hours format.
posted

I'd like to use the window's date format in my grid.  I have an unboundfield used to enter only the Time part of a date.  That field is binded to a DateTime property.  Even if my computer si set to Display in 24 hours format, the XamMaskedEditor will always use the 12 hours format, without showing AM nor PM.

Here is my UndoundField:

<igDP:UnboundField  x:Name="FieldTime"  Label="{x:Static cow:HealthResources.Time}" BindingPath="TreatmentTime" Row="1" Column="5" BindingMode="TwoWay">

              <igDP:UnboundField.Settings>

                <igDP:FieldSettings  Width="50"  EditorType="{x:Type igEditors:XamMaskedEditor}" LabelClickAction="Nothing" >

                  <igDP:FieldSettings.EditorStyle>

                    <Style TargetType="{x:Type igEditors:XamMaskedEditor}">

                        <Setter Property="Mask" Value="{}{time}" />

                        <Setter Property="Format" Value="hh:mm" />

                      </Style>

                  </igDP:FieldSettings.EditorStyle>

                </igDP:FieldSettings>

              </igDP:UnboundField.Settings>

            </igDP:UnboundField>

 

If I enter 22:45, the value is set correctly.  Whenever I load back this value in the grid, it gets displayed as 10:45, which is misleading because the AM/PM is not shown and the user is using 24 hours format anyway... that's what he is expecting to see.  

How do I force that control to use the system's format?

 

Parents
No Data
Reply
  • 54937
    Verified Answer
    Offline posted

    Just to be clear, the problem is when you are not in edit mode right? I think this issue is that you are using a format that uses a 12hour clock - "hh". If you want to use a 24 hour clock then you would use "HH". See MS' docs on the format characters - http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

    Remember too that WPF uses the Language property to determine the culture information and defaults to en-US and not necessarily what the user system has. I believe you could set the FormatProvider to the current thread's format. E.g. to do this for a standalone control:

    <igEditors:XamDateTimeEditor 
      xmlns:threading="clr-namespace:System.Threading;assembly=mscorlib"
      FormatProvider="{Binding Mode=OneTime, Source={x:Static threading:Thread.CurrentThread}, Path=CurrentCulture}"  />

Children
No Data