[英]How to localize DatePicker and TimePicker in WP8
我试图在WP7上本地化与工具包相关的DatePicker和TimePicker,但我不确定如何访问Header和应用程序栏文本。 我找不到任何显示完成这些任务的方法的链接。 是否有任何有用的链接或是否有人知道如何实现这许多?
DatePicker
和TimePicker
本地化。 如果您在2011年11月之前拥有Toolkit版本,
这很简单:参数 - 语言。 Xaml代码:
<toolkit:DatePicker Language="ru-RU" Margin="-12, 0" Value="{Binding BirthDate, Mode=TwoWay}" />
另一种不修改XAML源的替代方法是在页面加载后修改“HeaderTitle”TextBlock。
/// <summary>
/// Called from app.xaml.cs if the user navigates to the DatePickerPage
/// </summary>
/// <param name="page">The page.</param>
public static void DatePickerHook(PhoneApplicationPage page)
{
// Somehow modify the text on the top of the page...
LoopThroughControls(page, (ui => {
var tb = ui as TextBlock;
if (tb != null && tb.Name == "HeaderTitle")
{
tb.Text = "<<Local Translation>>";
}
}));
}
/// <summary>
/// Applies an action to every element on a page
/// </summary>
/// <param name="parent">The parent.</param>
/// <param name="modifier">The modifier.</param>
private static void LoopThroughControls(UIElement parent, Action<UIElement> modifier)
{
int count = VisualTreeHelper.GetChildrenCount(parent);
if (count > 0)
{
for (int i = 0; i < count; i++)
{
UIElement child = (UIElement)VisualTreeHelper.GetChild(parent, i);
modifier(child);
LoopThroughControls(child, modifier);
}
}
return;
}
以下是描述对app.xaml.cs的修改的博客文章的链接: http ://blog.dotnetframework.org/2015/11/09/localise-datepicker-in-wp8-silverlighttoolkit-using-hooks/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.