我已经本地化整个应用程序,但无法本地化日期选择器。在论坛中的一点搜索给了我几个答案like this one本地化默认的Windows手机日期选择器
但我无法找到一个与resx的属性文件夹为不同的lang for toolkit!我有jus在解决方案资源管理器中添加了工具包参考,并且可以访问日期选择器。我创建了一个名为toolkit.content的文件夹来放置ok和取消图像。
那么,如何添加RESX该工具包的日期选择器:(
我已经本地化整个应用程序,但无法本地化日期选择器。在论坛中的一点搜索给了我几个答案like this one本地化默认的Windows手机日期选择器
但我无法找到一个与resx的属性文件夹为不同的lang for toolkit!我有jus在解决方案资源管理器中添加了工具包参考,并且可以访问日期选择器。我创建了一个名为toolkit.content的文件夹来放置ok和取消图像。
那么,如何添加RESX该工具包的日期选择器:(
你必须得到该工具包中的源和您的本地化重建它
您也可以创建从原始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
}
}
并在CustomContr中创建选择器页面xaml文件OLS文件夹:
<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"
/>
后面的代码:
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);
}
}
这很简单:参数 - 语言。 XAML代码:
<toolkit:DatePicker Language="ru-RU" Margin="-12, 0" Value="{Binding BirthDate, Mode=TwoWay}" />
我没有下载源代码,进行修改,现在如何添加这个工具包?我无法找到DLL :( – alfah 2012-02-16 05:51:27
ToolKit构建源代码的根父级,所以无论你提取的源代码是一个Bin文件夹,它应该在Debug或Release文件夹中,我修复了这个文件夹 – MyKuLLSKI 2012-02-16 05:55:03
。有用的博客http://blogs.msdn.com/b/delay/archive/2010/12/20/quot-and-she-d-say-can-you-see-what-im-saying-quot-how-对局部化-A-Windows的电话7应用程序是用途最窗口电话的工具包成 - 不同,languages.aspx – alfah 2012-02-16 14:31:19