顯示具有 windows 8 標籤的文章。 顯示所有文章
顯示具有 windows 8 標籤的文章。 顯示所有文章

2012年11月22日 星期四

MessageBox for confirmation

Code snipplet:


 var messageBoxResult = MessageBox.Show(AppResources.TextDeleteConfrimation,  
             AppResources.TextDelete, MessageBoxButton.OKCancel);  
 if (messageBoxResult == MessageBoxResult.OK)  
 {  
   DeleteSomething();  
 }  


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));  
 }  



2012年9月20日 星期四

windows 8 set focus

It seems that there is no setFocus() method anymore. Instead, windows 8 includes the Windows.UI.Xaml.FocusState for different focus state, like: pointer, keyboard, etc.

The usage would be like:
ViewObjectName.Focus(Windows.UI.Xaml.FocusState.Pointer);

2012年9月10日 星期一

Run a program as administrator

http://www.intowindows.com/run-program-as-administrator-in-windows-8/


1. press windows to go to start screen
2. open search screen to search the program that you want to run. (i.e. cmd.exe)
3. the search result will be shown on the left hand side.
4. right click on it (tile of cmd.exe)
5. click on advanced
6. check run as adminstrator

2012年9月3日 星期一

Launch Browser with an URI from a win8 app

http://zubairahmed.net/?p=266

Here is the code snippet:
 Uri justUri = new Uri("http://www.google.com");  
 await Windows.System.Launcher.LaunchUriAsync(justUri);  

2012年8月12日 星期日

metro style -- switch to a new page

In metro style, when switching from a page to another page.
If the new page is a blank page when you add it into your project.


We usually do like this:


 this.Frame.Navigate(typeof(NewsPage), itemId);  



On the opening page, we need to implement onNavigateTo() method to do the corresponding jobs. Most cases, it is crucial to use the parameter that is passing in, i.e. itemId. here is an example of how to do it.



 protected override void OnNavigatedTo(NavigationEventArgs e)  
     {  
       base.OnNavigatedTo(e);  
       Story article = e.Parameter as Story;  
       BitmapImage bmpimg= getCoverImage(article);  
       if (null == bmpimg)  
       {  
         // todo: show empty image...  
       }  
       else  
       {  
         picture.Source = getCoverImage(article);  
       }  
 }  



or if it is a detail page when adding it,

put the code in LoadState(){}

2012年8月9日 星期四