微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SilverLight 4页面跳转大全

//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;

框架
 <navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}"
                              Source="/Views/About" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed">
                <navigation:Frame.UriMapper>
                  <uriMapper:UriMapper>
                    <uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
                    <uriMapper:UriMapping Uri="/Views/{pageName}" MappedUri="/Views/{pageName}.xaml"/>  
                    <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/{pageName}.xaml"/>
                  </uriMapper:UriMapper>
                </navigation:Frame.UriMapper>              
            </navigation:Frame> 
链接
<HyperlinkButton x:Name="userid" NavigateUri="/Views/Home"  Style="{StaticResource LinkStyle}" TargetName="ContentFrame" />
 
参考二:
问题:页面A跳转页面B.
方法:页面A的cs文件中:
1.先引入命名空间:
    using System.Windows.browser;
2.跳转语句:

HtmlWindow html  =  HtmlPage.Window;

html.Navigate(
new  Uri( " /Default.aspx " ,UriKind.Relative));
注意黑体字部分,如果要使用相对路径的话,必须加上,全路径的话,可以不用.
OK了,今天刚搞好的,也不知道可有其他办法了,再来找找,要有更好的办法,我再加进来吧.
转自:http://blog.csdn.net/lihaiyin/archive/2010/06/17/5674766.aspx

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐