问题
I have to route through different pages and pass routing parameters between them. I have made that happen and I am passing the parameters but I do not have access to the object property.
void itemClick(object sender, ItemClickEventArgs e)
{
this.Frame.Navigate(typeof(Views.SongPicker) , e.ClickedItem );
}
and on the other page I recive the parameter object as a navigation parameter.
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
}
I have no access to the object's properties. I would really appreciate the help.
回答1:
Try to cast the object to your type, like:
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
var param = navigationParameter as MyType;
}
And if the type is not nullable:
var param = (MyType)navigationParameter;
来源:https://stackoverflow.com/questions/13375845/win-8-rt-routing-parameters