Address: http://www.cnblogs.com/xieLongBao/archive/2012/02/26/2368377.html
Learn WP7 development with Mr Lin Yongjian
- Content Overview
- Use xaml for navigation
- Use C # code for navigation
- Address alias
- Data transmission between pages
- Back button
To better control navigation, we need to know the architecture and framework of the page:
- Frame
- Only one separate PhoneApplicationFrame
- Contains one or more phoneapplicationpages
- It also contains the system tray and application bar
- Page
- Contains titles and can have independent application Columns
- Page navigation
- SIlverlight for window phone uses page-based page navigation
- Similar to web page navigation
- Each Independent URI has a unique URI.
- Each Independent page is stateless.
After the introduction, the following is an example:
A very important control in the navigation: hyplinkbutton, So I first drag four hyplinkbuttons to the interface,
This is the home page. Next, create a new navigation page Music. xaml to the views directory, and add contant as the NavigateUri of the Music hyperlinkbutton.
In this way, you can start the program and navigate to the following three items according to the same operation,
Step 3: Use it on the page, modify the NavigationURi attribute of HyperLinkButton to the following, and complete the alias navigation.
?
<Grid x:Name= "ContentPanel" Grid.Row= "1" Margin= "12,0,12,0" > <HyperlinkButton Content= "Music" Height= "30" HorizontalAlignment= "Left" NavigateUri= "Music" Margin= "29,131,0,0" Name= "hyperlinkButton1" VerticalAlignment= "Top" Width= "115" /> <HyperlinkButton Content= "Video" Height= "30" HorizontalAlignment= "Left" NavigateUri= "Vedio" Margin= "29,60,0,0" Name= "Vedio" VerticalAlignment= "Top" Width= "115" /> <HyperlinkButton Content= "Browser" Height= "30" HorizontalAlignment= "Left" NavigateUri= "WebBrowser" Margin= "29,283,0,0" Name= "WebBrowser" VerticalAlignment= "Top" Width= "115" /> <HyperlinkButton Content= "Image" Height= "30" HorizontalAlignment= "Left" NavigateUri= "Picture" Margin= "29,207,0,0" Name= "hyperlinkButton4" VerticalAlignment= "Top" Width= "115" /> <Button Content= "Music" Height= "72" HorizontalAlignment= "Left" Margin= "241,131,0,0" Name= "musicbutton1" VerticalAlignment= "Top" Width= "160" Click= "musicbutton1_Click" /> <Button Content= "Video" Height= "72" HorizontalAlignment= "Left" Margin= "241,39,0,0" Name= "videobutton2" VerticalAlignment= "Top" Width= "160" Click= "videobutton2_Click" /> <Button Content= "Browser" Height= "72" HorizontalAlignment= "Left" Margin= "241,323,0,0" Name= "webbroserbutton3" VerticalAlignment= "Top" Width= "160" Click= "webbroserbutton3_Click" /> <Button Content= "Image" Height= "72" HorizontalAlignment= "Left" Margin= "241,225,0,0" Name= "picturebutton4" VerticalAlignment= "Top" Width= "160" Click= "picturebutton4_Click" /> </Grid> |
Modify the page
?
<HyperlinkButton Content= "Song 1" NavigateUri= "Music/Song 1" Height= "30" HorizontalAlignment= "Left" Margin= "175,230,0,0" Name= "hyperlinkButton2" VerticalAlignment= "Top" Width= "200" /> |
Note: NavigationService cannot pass objects by default (you can use static properties of the App class, SIngleton class, and break down the object into QueryString to pass ......)