This is a migrated thread and some comments may be shown as answers.

RadTimeBar localization problem

3 Answers 106 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
Robertyo Grifalconi
Top achievements
Rank 1
Robertyo Grifalconi asked on 20 Sep 2012, 07:13 AM
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

3 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 21 Sep 2012, 06:12 AM
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.

0
Robertyo Grifalconi
Top achievements
Rank 1
answered on 24 Sep 2012, 10:54 AM
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
0
Accepted
Tsvetie
Telerik team
answered on 27 Sep 2012, 01:16 PM
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.

Tags
TimeBar
Asked by
Robertyo Grifalconi
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Robertyo Grifalconi
Top achievements
Rank 1
Share this question
or