if (strXapOrXaml == "xaml") { string[] s = { "ClientBin" }; //这里控制是相对地址还是绝对地址 string url = ""; if (menuUrl.StartsWith("http://")) { url = menuUrl.ToString().Trim(); } else { url = App.Current.Host.source.OriginalString.ToString().Split(s,StringSplitOptions.RemoveEmptyEntries)[0] + menuUrl.ToString().Trim(new char[] { '.','/' }); } cpt.frmMain.Navigate(new Uri("/AspxContainer.xaml?tourl=" + url,UriKind.Relative)); tchA.imgRefresh.Tag = url; //获取页面URL地址并赋值 2013-01-30 }
这里比如url中带多个参数:
./YSQ/page2.aspx?stype=2&sdefault=0
<navigation:Page x:Class="WebMain.AspxContainer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" xmlns:divtools="clr-namespace:divelements.SilverlightTools;assembly=divelements.SilverlightTools" d:DesignWidth="640" d:DesignHeight="480" Title="AspxContainer Page"> <Grid x:Name="LayoutRoot"> <divtools:HtmlHost x:Name="htmlPlaceholderHost1" SourceUri="http://www.baidu.com" Margin="0,0"/> </Grid> </navigation:Page>
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Navigation; namespace WebMain { public partial class AspxContainer : Page { public AspxContainer() { InitializeComponent(); } // 当用户导航到此页面时执行。 protected override void OnNavigatedTo(NavigationEventArgs e) { if (this.NavigationContext.QueryString.ContainsKey("tourl")) { //加载页面 string url = e.Uri.ToString().Substring(26); //去掉前面的字符串/AspxContainer.xaml?tourl= this.htmlPlaceholderHost1.sourceUri = new Uri(url,UriKind.RelativeOrAbsolute); } } protected override void OnNavigatedFrom(NavigationEventArgs e) { base.OnNavigatedFrom(e); } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。