2012年11月11日 星期日

How to load a string from Resource.resw, and add a item to settings panel on Windows 8

The keyword is SettingsPane.

 In OnLaunched() in App.xaml.cs:
 SettingsPane.GetForCurrentView().CommandsRequested += CommandsRequested;  


Then implement CommandsRequested() itself.


     private void CommandsRequested(SettingsPane aSender, SettingsPaneCommandsRequestedEventArgs aEventArgs)  
     {  
       // Retrieve all the strings first  
       var loader = new Windows.ApplicationModel.Resources.ResourceLoader();  
       string settingsCommandId = loader.GetString("aText");  
       string label = loader.GetString("aText");  
       //add the commands to the setting panel  
       aEventArgs.Request.ApplicationCommands.Add(  
         new SettingsCommand(settingsCommandId, label, aMethod));  
 }  



沒有留言:

張貼留言