也许你可以实现一个自定义的urimapper来实现这一点。检查了这一点作为一个例子:Case sensitive UriMapper issue in Silverlight 3
..或
你可以尝试像
<uriMapper:UriMapping Uri="/Views/{myVar}Home" MappedUri="/Views/MainFrame.xaml"/>
<uriMapper:UriMapping Uri="/Views/{myVar}" MappedUri="/Views/Home.xaml?myVar={myVar}"/>
然后,在Home.xaml.cs,你应该能够做到以下几点:
this.Loaded += Home_Loaded;
...
public void Home_Loaded(object sender, RoutedEventArgs e)
{
if (this.NavigationContext.QueryString.ContainsKey("myVar"))
var v = this.NavigationContext.QueryString["myVar"];
//Now examine v. If it is in the correct format \d\d\d then continue.
//Else...redirect or throw exception
}
我想这可能是它,如果没有其他的方式 –
在那个线程中嗯有人说它使用正则表达式,这是正确的吗?这不应该有助于解决我的问题,如果这是真的吗? –
刚试过那个正则表达式,它不起作用。 –