silverlight中使用NavigationContext.QueryString动态加载文章
private void InitDocument(string _columnname) { YDZSWebServiceSoapClient client = new YDZSWebServiceSoapClient(); client.GetServerSidePathByColumCompleted += client_GetServerSidePathByColumCompleted; client.GetServerSidePathByColumAsync(_columnname); } void client_GetServerSidePathByColumCompleted(object sender, GetServerSidePathByColumCompletedEventArgs e) { byte[] stream = e.Result; DocxFormatProvider docxProvider = new DocxFormatProvider(); viewer.RadDocument = docxProvider.Import(stream); } // 当用户导航到此页面时执行。 protected override void OnNavigatedTo(NavigationEventArgs e) { Grid parent = App.Current.RootVisual as Grid; slApp.MainPage m = parent.Children.First() as slApp.MainPage; m.menu.SelectedTitle = "投资指南"; string _columnname; //如果带有查询参数,根据参数加载文章 if (this.NavigationContext.QueryString.ContainsKey("columnName")) { _columnname = Convert.ToString(this.NavigationContext.QueryString["columnName"]); InitDocument(_columnname); } } private void keysearch_Click(object sender, RoutedEventArgs e) { Grid parent = App.Current.RootVisual as Grid; slApp.MainPage m = parent.Children.First() as slApp.MainPage; string uriText = String.Format("GuidePage/ziliao?columnName={0}", txtkey.Text); m.ContentFrame.Navigate(new Uri(uriText,UriKind.Relative)); }