Win 8 RT routing parameters

旧街凉风 提交于 2019-12-10 18:49:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!