[英]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.