代码之家  ›  专栏  ›  技术社区  ›  funwithcoding

Silverlight 3业务应用程序:如何将查询字符串从主页传递到“关于”页?

  •  0
  • funwithcoding  · 技术社区  · 15 年前

    主页面由列表框、框架和几个超链接组成。单击超链接时,相应的页面将加载到框架中。

    如何通过Silverlight 3中的查询字符串将主页上列表框的选定项值传递给正在加载的页(例如:关于页)?

    任何提示都将受到高度赞赏。

    1 回复  |  直到 14 年前
        1
  •  1
  •   Johannes    15 年前

    按照 MSDN 页,您可以指定格式为的查询字符串

    <uriMapper:UriMapping Uri="/Products/{type}" 
      MappedUri="/Views/ProductDetail.xaml?producttype={type}">
    </uriMapper:UriMapping>
    

    我不知道如何通过XAML将类型链接到值,但在导航到该页时,可以添加onclick事件而不是navigateUri。在onclick事件中,您将指定如下内容:

    private void Link2_Click(object sender, RoutedEventArgs e)
    {
        Uri x = new Uri(String.Format(/Products/{0},yourcombo.SelectedItem), UriKind.Relative);
    
        //ContentFrame is the Navigation Frame
        ContentFrame.Navigate(x);
    }
    

    这将导航到productdetail.xaml页。从这里可以通过使用 string type = this.NavigationContext.QueryString["producttype"];

    蒂姆·豪尔也有一个优秀的 web cast 关于导航解决方案。