Windows Phone 8全球应用程序酒吧本地化
问题描述:
我想创建一个本地化的Windows Phone 8应用程序,并且我正在创建一个全局应用程序栏。然而,我无法使用资源设置栏内的项目文本,任何人都有一个想法如何做到这一点?我也无法在代码中获得它。Windows Phone 8全球应用程序酒吧本地化
答
您可以重复使用的模板的MainPage.xaml.cs中注释代码:
private void BuildLocalizedApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
// Create a new button and set the text value to the localized string from AppResources.
ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
//Search in AppResources.Search is a key of a string in the resource files (.resx)
appBarButton.Text = AppResources.Search;
ApplicationBar.Buttons.Add(appBarButton);
// Create a new menu item with the localized string from AppResources.
//Search in AppResources.Search is a key of a string in the resource files (.resx)
ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.Search);
ApplicationBar.MenuItems.Add(appBarMenuItem);
}
不幸的是,应用栏是不是一个传统的Silverlight控件,所以你必须在每一页编程方式创建,如果你想它本地化。