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(){}