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
}
精彩评论