将C#枚举值添加到导航URI
我正在开发一个Windows Phone应用程序。我在这里提出这个问题是因为我认为这是一个silverlight问题 我在App.xaml上定义了以下导航URI:将C#枚举值添加到导航URI,c#,silverlight,silverlight-3.0,windows-phone-7,C#,Silverlight,Silverlight 3.0,Windows Phone 7,我正在开发一个Windows Phone应用程序。我在这里提出这个问题是因为我认为这是一个silverlight问题 我在App.xaml上定义了以下导航URI: <!-- Navigation links--> <nav:UriMapper x:Name="UriMapper"> <nav:UriMapper.UriMappings> <nav:UriMapping Uri="/Destination" MappedUri="/
<!-- Navigation links-->
<nav:UriMapper x:Name="UriMapper">
<nav:UriMapper.UriMappings>
<nav:UriMapping Uri="/Destination" MappedUri="/Views/Tourism/Common.xaml?Type=1"/>
<nav:UriMapping Uri="/Points" MappedUri="/Views/Tourism/Common.xaml?Type=2"/>
</nav:UriMapper.UriMappings>
</nav:UriMapper>
我想更改MappedUri=“/Views/Tourism/Common.xaml?Type=1”上的“1”值,该值是从TourismItemType.Destination获得的
我想,我可以做到:
并以编程方式进行,但有没有办法访问XAML上TourismType.Destination表示的值
谢谢。这可以通过将枚举值作为字符串传递,然后在OnNavigatedTo事件中将其解析为枚举来轻松实现
MappedUri="/Views/Tourism/Common.xaml?Type=PointOfInterest"
然后在common.xaml中:
string selectedType = "";
if (NavigationContext.QueryString.TryGetValue("Type", out selectedType))
{
var tit = Enum.Parse(typeof (TourismItemType), selectedType, true);
// do something with `tit`...
}
string selectedType = "";
if (NavigationContext.QueryString.TryGetValue("Type", out selectedType))
{
var tit = Enum.Parse(typeof (TourismItemType), selectedType, true);
// do something with `tit`...
}