也許你可以實現一個自定義的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
}
我想這可能是它,如果沒有其他的方式 –
在那個線程中嗯有人說它使用正則表達式,這是正確的嗎?這不應該有助於解決我的問題,如果這是真的嗎? –
剛試過那個正則表達式,它不起作用。 –