【问题标题】:Silverlight 3 Navigation Framework: Query Custom URLsSilverlight 3 导航框架:查询自定义 URL
【发布时间】:2010-01-27 09:53:25
【问题描述】:

看来有了Silverlight 3 Navigation Framework,是可以像这样得到类似PHP的参数查询机制的:

mydomain.com/Views/News.xaml?title=SomeTitle

..并通过 Code-Behind 获取标题。

但我想要的是这样的:

mydomain.com/Views/SomeCustomText

我需要在 Code-Behind 中访问“SomeCustomText”(或 /Views/ 之后的任何自定义值)。这可能吗?

谢谢, 安德烈

【问题讨论】:

    标签: silverlight silverlight-3.0 navigation


    【解决方案1】:

    是的,如果我理解您的问题,这是可能的。 我会在框架中推荐如下内容:

    <uriMapper:UriMapping Uri="/Views/{myVar}" MappedUri="/Views/Main.xaml?myVar={myVar}"/>
    

    然后,在 Main.xaml.cs 中,您应该能够执行以下操作:

      this.Loaded += Main_Loaded;
       ...
      public void Main_Loaded(object sender, RoutedEventArgs e)
      {
        if (this.NavigationContext.QueryString.ContainsKey("myVar"))
          var v = this.NavigationContext.QueryString["myVar"];
          //v will be "SomeCustomText" if you went to mydomain.com/Views/SomeCustomText
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多