0

I have localised the whole app but not able to localise the date picker. A bit of searchin in the forum gave me few answers like this one

but i cant find a properties folder with the resx for different lang for toolkit! I have jus added the toolkit reference in the solution explorer under reference and thats im able to access date picker. I have made a folder called toolkit.content to put the ok and cancel images.

so how do i add the resx for the toolkit date picker :(

Community
  • 1
  • 1
alfah
  • 2,077
  • 1
  • 31
  • 55

3 Answers3

2

You can also create a custom control which inherits from the original DatePicker.

 public class MyDatePicker : Microsoft.Phone.Controls.DatePicker
{
    public string PickerPageHeader
    {
        get { return (string)GetValue(PickerPageHeaderProperty); }
        set { SetValue(PickerPageHeaderProperty, value); }
    }

    // Using a DependencyProperty as the backing store for PickerPageHeader.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty PickerPageHeaderProperty =
        DependencyProperty.Register("PickerPageHeader", typeof(string), typeof(MyDatePicker)
        , new PropertyMetadata("Choose date text in your language"));

    public MyDatePicker()
    {
        base.PickerPageUri = new Uri("/Sample;component/CustomControls/MyDatePickerPage.xaml?Header=" + PickerPageHeader, UriKind.Relative);
       //Don't forget to change the project name and xaml location
    }
}

And create picker page xaml file in a CustomControls folder:

<toolkit:DatePickerPage
x:Class="Sample.MyDatePickerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
/>

Code behind:

public partial class MyDatePickerPage : Microsoft.Phone.Controls.DatePickerPage
{
    public MyDatePickerPage ()
    {
        InitializeComponent();

        foreach (var item in base.ApplicationBar.Buttons)
        {
            IApplicationBarIconButton button = item as IApplicationBarIconButton;
            if (null != button)
            {
                if ("DONE" == button.Text.ToUpper())
                {
                    button.Text = "done in your language";
                }
                else if ("CANCEL" == button.Text.ToUpper())
                {
                    button.Text = "cancel in your language";
                }
            }
        }
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        (base.FindName("HeaderTitle") as TextBlock).Text = e.Uri.OriginalString.Substring(e.Uri.OriginalString.IndexOf("Header=") + 7);
        base.OnNavigatedTo(e);
    }
}
1

You have to get the source for the ToolKit and rebuild it with your localization

WP7 ToolKit Source

MyKuLLSKI
  • 5,285
  • 3
  • 20
  • 39
  • I did download the source, made modifications and now how do i add this toolkit? I cant find the dll :( – alfah Feb 16 '12 at 05:51
  • 1
    The source of the ToolKit build to the root parent. So wherever you extracted the source code is a Bin folder. It should be in a Debug or Release folder in there – MyKuLLSKI Feb 16 '12 at 05:55
  • i fixed it. This is a useful blog http://blogs.msdn.com/b/delay/archive/2010/12/20/quot-and-she-d-say-can-you-see-what-i-m-saying-quot-how-to-localize-a-windows-phone-7-application-that-uses-the-windows-phone-toolkit-into-different-languages.aspx – alfah Feb 16 '12 at 14:31
0

It's very simple: Parameter - Language. Xaml code:

<toolkit:DatePicker Language="ru-RU" Margin="-12, 0" Value="{Binding BirthDate, Mode=TwoWay}" />
Nickolas
  • 11
  • 2