开发者

Silverlight 3 Navigation Framework: Query Custom URLs

开发者 https://www.devze.com 2022-12-11 02:56 出处:网络
It seems that with the Silverlight 3 Navigation Framework, it is possible to get a PHP-like parameter query mechanism like so:

It seems that with the Silverlight 3 Navigation Framework, it is possible to get a PHP-like parameter query mechanism like so:

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

..and get th开发者_Python百科e title via Code-Behind.

But what I want is something like this:

mydomain.com/Views/SomeCustomText

I need to access "SomeCustomText" (or any custom value after /Views/ for that matter) in Code-Behind. Is this possible?

Thanks, Andrej


Yes, if I understand your question, it's possible. I'd recommend something like the following in the frame:

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

then, in Main.xaml.cs, you should be able to do the following:

  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
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消