Date formatting in ScheduleView doesn't follow current thread culture

3 posts, 0 answers
  1. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 15 Nov 2011 Link to this post

    After setting eveything i can think about to french, i still have some bound values in custom tooltips and custom event windows showing up in an english format. How can i have the thread set in french.

    Here's what i do in the initialization step of my Silverlight app
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr");
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr");
                Telerik.Windows.Controls.LocalizationManager.DefaultCulture = new System.Globalization.CultureInfo("fr");

    Then i have a custom tooltip:

    <DataTemplate x:Key="PlanificationTooltipTemplate">
                <Grid MaxWidth="300">
                    <StackPanel >
                        <StackPanel Orientation="Horizontal" Margin="0, 0,15, 0">
                            <TextBlock Text="{Binding Subject}" FontWeight="Bold" TextWrapping="Wrap" />
                            <TextBlock FontWeight="Bold"><Run Text=" - ("/></TextBlock>
                            <TextBlock Text="{Binding Appointment.Planification.Prestation.Produit}" FontWeight="Bold" TextWrapping="Wrap" />
                            <TextBlock FontWeight="Bold"><Run Text=")"/></TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock><Run Text="Client : "/></TextBlock>
                            <TextBlock Text="{Binding Appointment.Planification.Prestation.Client}" FontWeight="Bold" TextWrapping="Wrap" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock><Run Text="Site : "/></TextBlock>
                            <TextBlock Text="{Binding Appointment.Planification.Prestation.Site}" FontWeight="Bold" TextWrapping="Wrap" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Start, StringFormat=\{0:HH:mm\}}" TextWrapping="Wrap" />
                            <TextBlock><Run Text=" - "/></TextBlock>
                            <TextBlock Text="{Binding End, StringFormat=\{0:HH:mm\}}" TextWrapping="Wrap" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Visibility="{Binding Path=Appointment.Planification.PlanificationRecurrente, Converter={StaticResource BooleanToVisibilityConverter }}">
                            <Image x:Name="RecurrenceMark" Grid.Column="0" Margin="2 1 1 0" Width="10" Height="10" Visibility="{Binding Path=Appointment.Planification.PlanificationRecurrente, Converter={StaticResource BooleanToVisibilityConverter }}" HorizontalAlignment="Left" Source="{StaticResource AppointmentItem_Recurrence}" />
                            <TextBlock Text="{Binding  Appointment.Planification.PremiereRecurrence, StringFormat=\{0:d\}}" />
                            <TextBlock><Run Text=" au "/></TextBlock>
                            <TextBlock Text="{Binding  Appointment.Planification.DerniereRecurrence, StringFormat=\{0:d\}}" />
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </DataTemplate>
    where the bound values PremiereRecurrence and DerniereRecurrence, both formatted with {0:d} display in mm/DD/YYYY instead of the french value DD/mm/YYYY.

    What's the way to force a locale on the tooltip (i have the same problem with an custom edit window for Appointments)?
  2. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 18 Nov 2011 Link to this post

    Any idea? i could force the date to display with the right format but i'd rather rely on the current culture i'm working on.
  3. DevCraft banner
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 18 Nov 2011 Link to this post

    Hello Samy,

    I am afraid that you need to set these format strings in XAML. The other option is to use a Converter and convert the dates according to the set Culture.


    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top