刚刚倒腾这个Toolkit,很蛋疼地发现点击修改之后里面的文字是英文。怎么改呢???这是我在网上找到的代码:
首先在App.xaml.cs里的Application_Launching函数里加一句话:
RootFrame.Navigated += RootFrame_Navigated;
然后RootFrame_Navigated函数如下:
void RootFrame_Navigated(object sender, NavigationEventArgs e) { if (e.Uri == null || e.Content == null || (!(e.Content is DatePickerPage) && !(e.Content is TimePickerPage)) || (e.Uri.OriginalString != "/Microsoft.Phone.Controls.Toolkit;component/DateTimePickers/DatePickerPage.xaml" && e.Uri.OriginalString != "/Microsoft.Phone.Controls.Toolkit;component/DateTimePickers/TimePickerPage.xaml")) return; PhoneApplicationPage page = null; string pageTitle; if (e.Content is DatePickerPage) { page = (DatePickerPage)e.Content; pageTitle = "选择日期"; } else { page = (TimePickerPage)e.Content; pageTitle = "选择时间"; } ((TextBlock)((Grid)((FrameworkElement)page.FindName("SystemTrayPlaceholder")).Parent).Children.First(c => c.GetType() == typeof(TextBlock))).Text = pageTitle; ((ApplicationBarIconButton)page.ApplicationBar.Buttons[0]).Text = "确定"; ((ApplicationBarIconButton)page.ApplicationBar.Buttons[1]).Text = "取消"; }
如果说你的Children.First下面划红线了,可以加一个using System.Linq;
晓得了不? 因为First是Linq里集成的函数,只有加上using才能出现~。~