RadTimeBar localization problem

4 posts, 1 answers
  1. Robertyo Grifalconi
    Robertyo Grifalconi avatar
    5 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    Hi,
    i need to change at run time the culture of all controls used in my application, but i've a RadTimeBar's localization problem.

    I've try to use the solution posted by Evgenia in the "TimeBar Localization does not work - please help" thread with a button that set the French culture on click, but it doesn't work for me.

    My code behind is:

            private void btn_Click(object sender, RoutedEventArgs e)
            {
                CultureInfo culture = new CultureInfo("fr");
                System.Threading.Thread.CurrentThread.CurrentCulture = culture;
                System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
            }

    The only way to change the language of RadTimeBar's labels is to destroy and recreate the RadTimeBar on windows loaded, because nothing changes if i only set the Culture.

    I'm using Q3-2011 version, there's any other solution for this problem?

    Thanks,

    Rob
  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 21 Sep 2012 Link to this post

    Hi Rob,

    Please check the solution in this online demo. The demo itself is for RadScheduleView, but the approach is valid for RadTimeBar as well. 

    Regards,
    Tsvetie
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Robertyo Grifalconi
    Robertyo Grifalconi avatar
    5 posts
    Member since:
    Sep 2012

    Posted 24 Sep 2012 Link to this post

    Hi Tsvetie, thanks for your reply.

    I've try to replicate the solution finded in the online demo but doesn't work for my RadTimeBar because if i call the ResetTemplate method in the OnLoaded method i've got an exception.

    To replicate this exception you could takes the code in the "ScheduleView with TimeBar" demo and add

    this
    .Loaded += new System.Windows.RoutedEventHandler(Example_Loaded);

    and

    void Example_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        Telerik.Windows.Controls.LocalizationManager.DefaultCulture = new CultureInfo("de"); 
        ResetTemplate();
    }
    .

    I've also update my telerik dlls to WPF Q2 2012 SP2.

    Please help me to resolve this problem.

    Thanks.
    Rob
  5. Answer
    Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 27 Sep 2012 Link to this post

    Hello Rob,

    In order to fix the exception that you get in the modified version of our "ScheduleView with TimeBar" demo, you need to make two additional changes. First, please remove the Intervals collection from the RadTimeBar definition in Example.xaml:

    <telerik:RadTimeBar x:Name="TimeBar" Margin="2" Grid.ColumnSpan="2"
        telerik:StyleManager.Theme="Metro" Background="Transparent" PeriodStart="1/1/2011 12:00:00 AM"
        PeriodEnd="12/31/2011 11:59:59 PM" VisiblePeriodStart="5/1/2011 12:00:00 AM"
        VisiblePeriodEnd="7/30/2011 11:59:59 PM" SelectionStart="6/2/2011 10:00:00 AM"
        SelectionEnd="6/9/2011 10:00:00 AM" MinSelectionRange="1.00:00:00" MaxSelectionRange="31.00:00:00"
        MinZoomRange="31.00:00:00" IsSnapToIntervalEnabled="True"
        VisiblePeriodChanged="TimeBar_VisiblePeriodChanged">
    </telerik:RadTimeBar>

    Additionally, update the ResetTemplate method the following way:

    private void ResetTemplate()
    {
        var minSelectionRange = this.TimeBar.MinSelectionRange;
        System.Windows.Controls.ControlTemplate template = this.TimeBar.Template;
     
        this.TimeBar.MinSelectionRange = TimeSpan.Zero;
        this.TimeBar.Intervals.Clear();
        this.TimeBar.Template = null;
     
        this.TimeBar.Template = template;
        this.TimeBar.MinSelectionRange = minSelectionRange;
     
        this.TimeBar.Intervals.AddRange(new List<IntervalBase>(){ new YearInterval(), new MonthInterval(), new WeekInterval(), new DayInterval() });
    }

    All the best,
    Tsvetie
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Back to Top