in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

C1DateTimePicker doesn't respect culture setting

Last post 06-16-2008 3:36 PM by C1_IrinaP. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-16-2008 1:37 PM

    C1DateTimePicker doesn't respect culture setting

    Hi,
    I set global culture for my application to Vietnam like this in app.cs:
    // Set default culture to VN
    CultureInfo ci = new System.Globalization.CultureInfo("vi-VN");
    System.Threading.
    Thread.CurrentThread.CurrentUICulture = ci;
    System.Threading.
    Thread.CurrentThread.CurrentCulture = ci;

    Everything is OK, including format datetime, C1Schedule, C1MonthCalendar, they got format correctly but not C1DateTimePicker.
    I finally found that coming from default template of this control, it's using DateTimeToStringConverter class to convert value selected in drop-down calendar to string. I can change parameter pass to converter for textbox to fix format to "dd/MM/yy" but i can not do the same way for TextBlock to show short date name as it's "ddd", result still be Mon for Monday, in Vietnamese Monday is THai.

    So C1 have to fix Converter class to respect application culture setting or can i do anything as work-around.

    Extract lines from template

    <StackPanel Name="dateText" Orientation="Horizontal" Margin="0">

    <TextBlock

    Text="{Binding SelectedValue, RelativeSource={RelativeSource TemplatedParent},

    Converter={x:Static c1sched:DateTimeToStringConverter.Default},

    ConverterParameter=ddd}"/>

    <TextBox BorderThickness="0" Style="{x:Null}"

    Validation.ErrorTemplate="{DynamicResource ovalValidationTemplate}">

    <TextBox.Text>

    <Binding Path="SelectedValue"

    RelativeSource="{RelativeSource TemplatedParent}"

    Converter="{x:Static c1sched:DateTimeToStringConverter.Default}"

    ConverterParameter="dd/MM/yy"

    NotifyOnValidationError="true"

    UpdateSourceTrigger="PropertyChanged">

    <Binding.ValidationRules>

    <c1sched:DateTimeStringValidator Format="d" />

    </Binding.ValidationRules>

    </Binding>

    </TextBox.Text>

    </TextBox>

    </StackPanel>

  • 06-16-2008 1:50 PM In reply to

    Re: C1DateTimePicker doesn't respect culture setting

    Hmm, found a solution. Just add ConverterCulture to Converer in xaml like this:

    <TextBlock Text="{Binding SelectedValue, RelativeSource={RelativeSource TemplatedParent},
    Converter={x:Static c1sched:DateTimeToStringConverter.Default},
    ConverterParameter=ddd, ConverterCulture=vi-VN}"/>

    it works but better if i did nothing, it should be default in DateTimeToString converter class or default template.

  • 06-16-2008 3:36 PM In reply to

    Re: C1DateTimePicker doesn't respect culture setting

    > Hmm, found a solution. Just add ConverterCulture to Converer in xaml like this:
    >
    >
    > Converter={x:Static c1sched:DateTimeToStringConverter.Default},
    > ConverterParameter=ddd, ConverterCulture=vi-VN}"/>
    >
    > it works but better if i did nothing, it should be default in DateTimeToString converter
    > class or default template.
    Thak you for posting your solution here.
    We have quite long todo list for C1DateTimePicker control.
Page 1 of 1 (3 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.