天天看點

SilverLight 4頁面跳轉大全

<a href="http://blog.csdn.net/lihaiyin/article/details/5674766">http://blog.csdn.net/lihaiyin/article/details/5674766</a>

//Silverlight頁面的跳轉 

//(Application.Current.RootVisual as IContent).Content = new DragControl(); 

//普通頁面跳轉 

HtmlWindow html = HtmlPage.Window; 

//html.Navigate(new Uri("http://www.0379zd.com"));//普通網址 

html.Navigate(new Uri("../Index.aspx", UriKind.Relative));//相對路徑

參考一:

方法一: 可跳轉到網頁 

                  HtmlWindow html = HtmlPage.Window; 

                  html.Navigate(new Uri(item.Link_Page.Trim(), UriKind.Relative), "_blank"); 

                   //System.Windows.Browser.HtmlPage.PopupWindow(new Uri(HtmlPage.Document.DocumentUri, item.Link_Page.Trim()), "_Blank",null); 

方法二:跳轉到Xaml頁 

            this.Content = new About(); 

方法三:架構跳轉item.Link_Page.Trim():代表xaml名 e.g: /views/home   

           events = new System.Uri(item.Link_Page.Trim(), UriKind.Relative); 

           this.ContentFrame.Source = events; 

架構 

 &lt;navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" 

                              Source="/Views/About" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed"&gt; 

                &lt;navigation:Frame.UriMapper&gt; 

                  &lt;uriMapper:UriMapper&gt; 

                    &lt;uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/&gt; 

                    &lt;uriMapper:UriMapping Uri="/Views/{pageName}" MappedUri="/Views/{pageName}.xaml"/&gt;   

                    &lt;uriMapper:UriMapping Uri="/{pageName}" MappedUri="/{pageName}.xaml"/&gt; 

                  &lt;/uriMapper:UriMapper&gt; 

                &lt;/navigation:Frame.UriMapper&gt;               

            &lt;/navigation:Frame&gt;  

連結 

&lt;HyperlinkButton x:Name="userid" NavigateUri="/Views/Home"  Style="{StaticResource LinkStyle}" TargetName="ContentFrame" /&gt;

參考二:

問題:從頁面A跳轉到頁面B. 

方法:在頁面A的cs檔案中: 

1.先引入命名空間: 

    using System.Windows.Browser; 

2.跳轉語句:

SilverLight 4頁面跳轉大全
SilverLight 4頁面跳轉大全

html.Navigate(new Uri("/Default.aspx",UriKind.Relative));

注意黑體字部分,如果要使用相對路徑的話,必須加上,全路徑的話,可以不用. 

OK了,今天剛搞好的,也不知道可有其他辦法了,再來找找,要有更好的辦法,我再加進來吧.

本文轉自cnn23711151CTO部落格,原文連結:http://blog.51cto.com/cnn237111/622829 ,如需轉載請自行聯系原作者

繼續閱讀