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

Changing language localization in raddatapager

14 Answers 234 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 2
Anthony asked on 03 Oct 2011, 09:09 AM
Hello Telerik Team,

I managed to use custom localization in raddatapager, but when I tried to change it dynamically it wont change. Reloading the page I think is the way to change it, but I dont want to reload the silverlight page just to only change the language localization of the pager.

Anyone who has a solution for this? Dynamically changing the raddatapager localization without refreshing?

14 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Oct 2011, 10:14 AM
Hi Anthony,

Indeed, in order to change the language of your application, you have to reload it. So, you may either use the approach illustrated in the project of the forum thread or benefit from the Navigation Framework. Unfortunately, both solutions are not as simple as clicking on a button setting the CurrentCulture property. Another possibility would be to predefine all templates and bind the corresponding localized properties. However, this would be more time-consuming than the approaches above.
 

Regards,
Maya
the Telerik team

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

0
Anthony
Top achievements
Rank 2
answered on 03 Oct 2011, 10:30 AM
Hello Maya,

Is there a more simpler way to do this like, I can bind the "Page 1 of 1" in a property in order to change it at run time using notifypropertychange event?

In our RadGridViews, I managed to change the header text dynamically using DataContextProxy from the solution you gave us, the header texts are bound to a property inside the view model. This control has also group panel which needs to be localized sometime if it is needed for the project. This group panel problem will be related to the problem I am asking now with the raddatapager pager text, so I really need urgent assistance for this problem.

Thank you

Anthony
0
Maya
Telerik team
answered on 04 Oct 2011, 09:08 AM
Hello Anthony,

Generally, you can extract the template of RadDataPager and bind all Text properties of the elements to the value you want. I am sending you a sample project illustrating how you can do that with the text inside the group panel of RadGridView. 
However, this will get quite much complicated if you require to do the same for the filtering control for example. So, I would definitely recommend you to use one of the previously suggested approaches:
1. Reload the elements you want to localized.
2. Use Navigation Framework.

 

Regards,
Maya
the Telerik team

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

0
Anthony
Top achievements
Rank 2
answered on 04 Oct 2011, 09:38 AM
Hello Maya,

Thanks a lot, I will try your solution and will get back on you for feedback.

Regards,

Anthony
0
Anthony
Top achievements
Rank 2
answered on 12 Oct 2011, 10:02 AM
Hello Maya,

I managed to edit the template of the raddatapager. But there are some problems with the xaml designer, there is an error:

"Error    140    Type 'controls:RadDataPagerCommands' was not found.    C:\Data\Program\CMSilverlight\ManorSL\Composition\CompositionMain.xaml    313    23    Composition"

That's the error in design mode, but in run time it works well. I will show you a screen shot of the error.
0
Maya
Telerik team
answered on 13 Oct 2011, 09:32 AM
Hello Anthony,

Do you continue to get the same error after cleaning and rebuilding the project? Is the "MoveToFirstPage" button of the pager working correctly when you run the application ? Do you get the same error if you place a button outside the pager and setting the exact same command ?

Regards,
Maya
the Telerik team

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

0
Anthony
Top achievements
Rank 2
answered on 13 Oct 2011, 09:44 AM
Hello Maya,

Yes I'm still getting the error even when cleaning and rebuilding and when I run the application, the "MoveToFirstPage" is working. If I remove the part with error, the other button will also throw an error until no button is left. That's kind of weird isn't it? Also does MS Expression Blend 4 affect that? Anyway, all of the buttons in the pager are all working in run time. But the third one that you said, how could I place the button outside of a raddatapager?

By the way here's my code.

<telerik:RadDataPager
                      x:Name="pagerComposition"
                      Grid.Row="1"
                      PageSize="10"
                      Source="{Binding ProductCompositionList}"
                      AutoEllipsisMode="Both"
                      NumericButtonCount="10"
                      DisplayMode="FirstLastPreviousNextNumeric,Text"
                      FontSize="9"
                      VerticalAlignment="Bottom" BorderBrush="{x:Null}"
                      Height="Auto">
 
                  <telerik:RadDataPager.Resources>
                      <telerik:Office_BlackTheme x:Key="Theme"/>
                      <SolidColorBrush x:Key="RadPager_Indicator" Color="Black"/>
                      <LinearGradientBrush x:Key="RadPager_NumericPresenter_Border" EndPoint="0.5,1" StartPoint="0.5,0">
                          <GradientStop Color="#FF494949" Offset="0"/>
                          <GradientStop Color="#FF9D9D9D" Offset="1"/>
                      </LinearGradientBrush>
                      <SolidColorBrush x:Key="RadPager_NumericPresenter_Background" Color="#FF929292"/>
                      <SolidColorBrush x:Key="RadPager_Separator1" Color="White"/>
                      <SolidColorBrush x:Key="RadPager_Separator2" Color="#FF848484"/>
                      <ControlTemplate x:Key="DataPagerPresenterTemplate" TargetType="Telerik_Windows_Controls_Data_DataPager:DataPagerPresenter">
                          <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                              <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                  <Grid.ColumnDefinitions>
                                      <ColumnDefinition Width="*"/>
                                      <ColumnDefinition Width="Auto"/>
                                  </Grid.ColumnDefinitions>
                                  <StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Orientation="Horizontal" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                      <telerik:RadButton x:Name="MoveToFirstPageButton" Command="controls:RadDataPagerCommands.MoveToFirstPage" Height="18" Margin="2" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding PagerControlsVisibility.MoveToFirstPageControlVisibility, RelativeSource={RelativeSource TemplatedParent}}" Width="18">
                                          <StackPanel Orientation="Horizontal">
                                              <Rectangle Fill="{StaticResource RadPager_Indicator}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="1"/>
                                              <Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource RadPager_Indicator}" HorizontalAlignment="Center" Height="7" RenderTransformOrigin="0.5, 0.5" VerticalAlignment="Center" Width="4">
                                                  <Path.RenderTransform>
                                                      <TransformGroup>
                                                          <ScaleTransform ScaleY="1" ScaleX="-1"/>
                                                          <SkewTransform AngleY="0" AngleX="0"/>
                                                          <RotateTransform Angle="0"/>
                                                          <TranslateTransform/>
                                                      </TransformGroup>
                                                  </Path.RenderTransform>
                                              </Path>
                                          </StackPanel>
                                      </telerik:RadButton>
                                      <telerik:RadButton x:Name="MoveToPreviousPageButton" Command="controls:RadDataPagerCommands.MoveToPreviousPage" Height="18" Margin="2" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding PagerControlsVisibility.MoveToPreviousPageControlVisibility, RelativeSource={RelativeSource TemplatedParent}}" Width="18">
                                          <Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource RadPager_Indicator}" HorizontalAlignment="Center" Height="7" RenderTransformOrigin="0.5, 0.5" VerticalAlignment="Center" Width="4">
                                              <Path.RenderTransform>
                                                  <TransformGroup>
                                                      <ScaleTransform ScaleY="1" ScaleX="-1"/>
                                                      <SkewTransform AngleY="0" AngleX="0"/>
                                                      <RotateTransform Angle="0"/>
                                                      <TranslateTransform/>
                                                  </TransformGroup>
                                              </Path.RenderTransform>
                                          </Path>
                                      </telerik:RadButton>
                                      <Border BorderBrush="{StaticResource RadPager_NumericPresenter_Border}" BorderThickness="1,0,0,0" Background="{StaticResource RadPager_NumericPresenter_Background}" Height="20" Visibility="{Binding PagerControlsVisibility.NumericElementsControlVisibility, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center">
                                          <Telerik_Windows_Controls_Data_DataPager:NumericElementsPresenter AutoEllipsisMode="{TemplateBinding AutoEllipsisMode}" NumericButtonStyle="{TemplateBinding NumericButtonStyle}" NumericButtonCount="{TemplateBinding NumericButtonCount}" PageCount="{TemplateBinding PageCount}" PageIndex="{TemplateBinding PageIndex}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                                      </Border>
                                      <telerik:RadButton x:Name="MoveToNextPageButton" Command="controls:RadDataPagerCommands.MoveToNextPage" Height="18" Margin="2" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding PagerControlsVisibility.MoveToNextPageControlVisibility, RelativeSource={RelativeSource TemplatedParent}}" Width="18">
                                          <Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource RadPager_Indicator}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="4"/>
                                      </telerik:RadButton>
                                      <telerik:RadButton x:Name="MoveToLastPageButton" Command="controls:RadDataPagerCommands.MoveToLastPage" Height="18" Margin="2" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding PagerControlsVisibility.MoveToLastPageControlVisibility, RelativeSource={RelativeSource TemplatedParent}}" Width="18">
                                          <StackPanel Orientation="Horizontal">
                                              <Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource RadPager_Indicator}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="4"/>
                                              <Rectangle Fill="{StaticResource RadPager_Indicator}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="1"/>
                                          </StackPanel>
                                      </telerik:RadButton>
                                  </StackPanel>
                                  <StackPanel Grid.Column="1" Margin="5,0" Orientation="Horizontal" Visibility="{Binding PagerControlsVisibility.TextControlVisibility, RelativeSource={RelativeSource TemplatedParent}}">
                                      <Border Background="{StaticResource RadPager_Separator1}" HorizontalAlignment="Left" Height="18" Margin="5,0,0,0" VerticalAlignment="Center" Width="1"/>
                                      <Border Background="{StaticResource RadPager_Separator2}" HorizontalAlignment="Left" Height="18" Margin="0,0,10,0" VerticalAlignment="Center" Width="1"/>
                                      <TextBlock Margin="2,0" Text="{Binding DataSource.LabelPage, Source={StaticResource DataContextProxy}}" VerticalAlignment="Center"/>
                                      <Telerik_Windows_Controls_Data_DataPager:DataPagerTextBox Command="controls:RadDataPagerCommands.MoveToPage" Height="20" Margin="2,0" PageIndex="{TemplateBinding PageIndex}" telerik:StyleManager.Theme="{StaticResource Theme}" VerticalAlignment="Center" Width="48"/>
                                      <TextBlock Margin="2,0" Text="{Binding DataSource.LabelOf, Source={StaticResource DataContextProxy}}" VerticalAlignment="Center"/>
                                      <TextBlock Margin="2,0" Text="{Binding PageCount, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center"/>
                                  </StackPanel>
                              </Grid>
                          </Border>
                      </ControlTemplate>
                      <Style x:Key="DataPagerPresenterStyle1" TargetType="Telerik_Windows_Controls_Data_DataPager:DataPagerPresenter">
                          <Setter Property="Template" Value="{StaticResource DataPagerPresenterTemplate}"/>
                      </Style>
                      <ControlTemplate x:Key="RadDataPagerTemplate" TargetType="telerik:RadDataPager">
                          <Telerik_Windows_Controls_Data_DataPager:DataPagerPresenter AutoEllipsisMode="{TemplateBinding AutoEllipsisMode}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" DisplayMode="{TemplateBinding DisplayMode}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" ItemCount="{Binding ItemCount, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" NumericButtonStyle="{TemplateBinding NumericButtonStyle}" NumericButtonCount="{TemplateBinding NumericButtonCount}" PageCount="{TemplateBinding PageCount}" PageSize="{Binding PageSize, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" PageIndex="{TemplateBinding PageIndex}" telerik:StyleManager.Theme="{StaticResource Theme}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Style="{StaticResource DataPagerPresenterStyle1}"/>
                      </ControlTemplate>
                      <LinearGradientBrush x:Key="RadPager_Background" EndPoint="0.5,1" StartPoint="0.5,0">
                          <GradientStop Color="#FFB5B5B5"/>
                          <GradientStop Color="#FFF0F0F0" Offset="0.5"/>
                      </LinearGradientBrush>
                      <SolidColorBrush x:Key="RadPager_Border" Color="#FF848484"/>
                      <SolidColorBrush x:Key="RadPager_Foreground" Color="Black"/>
                      <LinearGradientBrush x:Key="RadPager_Page_TopShadow" EndPoint="0.5,1" StartPoint="0.5,0">
                          <GradientStop Color="#66000000" Offset="0"/>
                          <GradientStop Offset="0.3"/>
                      </LinearGradientBrush>
                      <LinearGradientBrush x:Key="RadPager_Page_Over" EndPoint="0.5,0.99" StartPoint="0.5,0.01">
                          <GradientStop Color="#FFFFFBB7" Offset="0.216"/>
                          <GradientStop Color="#FFBDBDBD"/>
                      </LinearGradientBrush>
                      <LinearGradientBrush x:Key="RadPager_Page_Checked" EndPoint="0.5,0.99" StartPoint="0.5,0.01">
                          <GradientStop Color="#FFFFDB7B" Offset="0.5"/>
                          <GradientStop Color="#FFC58124"/>
                      </LinearGradientBrush>
                      <LinearGradientBrush x:Key="RadPager_Page_Disabled" EndPoint="0.5,0.99" StartPoint="0.5,0.01">
                          <GradientStop Color="#FFD8D8D8" Offset="0.216"/>
                          <GradientStop Color="#FFBDBDBD"/>
                      </LinearGradientBrush>
                      <ControlTemplate x:Key="RadPageTemplate" TargetType="telerik:RadRadioButton">
                          <Border x:Name="PageButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0,0,6,1">
                              <VisualStateManager.VisualStateGroups>
                                  <VisualStateGroup x:Name="CommonStates">
                                      <VisualState x:Name="Normal"/>
                                      <VisualState x:Name="MouseOver">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetProperty="Background" Storyboard.TargetName="PageButton">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadPager_Page_Over}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Pressed">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetProperty="Background" Storyboard.TargetName="PageButton">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadPager_Page_Checked}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Disabled">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetProperty="Background" Storyboard.TargetName="PageButton">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadPager_Page_Disabled}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Checked">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetProperty="Background" Storyboard.TargetName="PageButton">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadPager_Page_Checked}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="FocuseStatesGroup">
                                      <VisualState x:Name="Unfocused"/>
                                      <VisualState x:Name="Focused">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetProperty="Background" Storyboard.TargetName="PageButton">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadPager_Page_Over}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                  </VisualStateGroup>
                              </VisualStateManager.VisualStateGroups>
                              <Border Background="{StaticResource RadPager_Page_TopShadow}">
                                  <ContentControl Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsTabStop="False" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                              </Border>
                          </Border>
                      </ControlTemplate>
                      <LinearGradientBrush x:Key="RadPager_Page_Background" EndPoint="0.5,1" StartPoint="0.5,0">
                          <GradientStop Color="White" Offset="0.216"/>
                          <GradientStop Color="#FFBDBDBD"/>
                      </LinearGradientBrush>
                      <LinearGradientBrush x:Key="RadPager_Page_Border" EndPoint="0.5,1" StartPoint="0.5,0">
                          <GradientStop Color="#FF494949" Offset="0"/>
                          <GradientStop Color="#FF9D9D9D" Offset="1"/>
                      </LinearGradientBrush>
                      <Style x:Key="RadPageStyle" TargetType="telerik:RadRadioButton">
                          <Setter Property="Template" Value="{StaticResource RadPageTemplate}"/>
                          <Setter Property="Background" Value="{StaticResource RadPager_Page_Background}"/>
                          <Setter Property="BorderBrush" Value="{StaticResource RadPager_Page_Border}"/>
                          <Setter Property="BorderThickness" Value="0,0,1,1"/>
                          <Setter Property="MinWidth" Value="21"/>
                          <Setter Property="HorizontalContentAlignment" Value="Center"/>
                          <Setter Property="VerticalContentAlignment" Value="Center"/>
                          <Setter Property="Padding" Value="0"/>
                      </Style>
                      <Style x:Key="RadDataPagerStyle1" TargetType="telerik:RadDataPager">
                          <Setter Property="Template" Value="{StaticResource RadDataPagerTemplate}"/>
                          <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                          <Setter Property="VerticalContentAlignment" Value="Center"/>
                          <Setter Property="Background" Value="{StaticResource RadPager_Background}"/>
                          <Setter Property="BorderBrush" Value="{StaticResource RadPager_Border}"/>
                          <Setter Property="BorderThickness" Value="1"/>
                          <Setter Property="Foreground" Value="{StaticResource RadPager_Foreground}"/>
                          <Setter Property="NumericButtonStyle" Value="{StaticResource RadPageStyle}"/>
                          <Setter Property="Height" Value="28"/>
                          <Setter Property="FontSize" Value="9"/>
                      </Style>
                  </telerik:RadDataPager.Resources>
                  <telerik:RadDataPager.Style>
                      <StaticResource ResourceKey="RadDataPagerStyle1"/>
                  </telerik:RadDataPager.Style>
 
 
              </telerik:RadDataPager>
0
Maya
Telerik team
answered on 17 Oct 2011, 08:44 AM
Hello Anthony,

I have tried to reproduce the same behavior and get the error you have, but still without any success. I am sending you the sample project I used for testing the case. Generally, it uses the code-snippet you provided.
Can you get the same error on your side ?
 

Kind regards,
Maya
the Telerik team

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

0
Anthony
Top achievements
Rank 2
answered on 17 Oct 2011, 09:04 AM
Hello Maya,

I'm still getting the same error. I captured a screenshot for you to see. You said its working on your side, it seems that there's something that conflicts within my designer. Do you have idea?

Regards,

Anthony
0
Vanya Pavlova
Telerik team
answered on 17 Oct 2011, 11:29 AM
Hi Anthony,

 


Generally you have to ensure that all references in your project are with the same version and they point to an existing path. May you please check this one and let me know how it goes?
You may check the sample project for further reference.




Best wishes,
Vanya Pavlova
the Telerik team

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

0
Anthony
Top achievements
Rank 2
answered on 17 Oct 2011, 11:39 AM
Hello Vanya,

I downloaded the sample project from your post but still getting the same error. I captured my screen for you to see the error.
I don't know what's causing this, is there other way? Or could you remote my PC so that can see what's the problem?

Regards,

Anthony
0
Anthony
Top achievements
Rank 2
answered on 17 Oct 2011, 11:44 AM
I also had it rebuild, and it succeeded. When I reload the designer, the error still happens. I really need to resolve that so our programmers will easily see the changes they made from the designer. If that wouldn't be resolve, every time we modify our design we need to comment first that part.
0
Matt
Top achievements
Rank 1
answered on 10 Nov 2011, 06:56 PM
I too had this issue and what resolved it was changing "controls:RadDataPagerCommands" to "telerik:RadDataPagerCommands". The telerik prefix matches my namespace declaration of
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  
0
Carlos
Top achievements
Rank 1
answered on 28 Feb 2012, 12:56 PM
I can confirm that Matt's solution quickly resolves this issue. I too was having the exact same problem.
Tags
DataPager
Asked by
Anthony
Top achievements
Rank 2
Answers by
Maya
Telerik team
Anthony
Top achievements
Rank 2
Vanya Pavlova
Telerik team
Matt
Top achievements
Rank 1
Carlos
Top achievements
Rank 1
Share this question
or