wp7页面传值

来源:互联网 发布:informix数据库版本 编辑:程序博客网 时间:2024/05/22 07:55
以前做web开发,经常在页面之间来回传值,今天,在练习一个wp7小的项目时,要从main.xaml 向method.xaml传入两个参数值,自己看的教学资料中,都只是传了一个值,今天要传两个,呵呵,无所谓,凭借web开发的经验,立马就写了出来: <HyperlinkButton Content="Math" FontSize="32" Height="50" HorizontalContentAlignment="Left" Name="hyperlinkButton1"  NavigateUri="/method.xaml?type=math&detail=good" />,写完一调试,悲催,跳转失败……哎,看来,web开发的经验,还不能直接迁移过来了,哈哈,不过,虽然调试失败了,但相信大道至简的道理,你wp7再怎么厉害,页面传值,量你也跑不出这种模式。认准了方向,就努力研究吧,哈哈,不一会,就发现问题了,就像在web中,用&nbsp;代表空格一样,wp7中,要求用&amp;来代表&符号,哈哈,发现问题,解决问题,立刻更正代码:<HyperlinkButton Content="Math" FontSize="32" Height="50" HorizontalContentAlignment="Left" Name="hyperlinkButton1"  NavigateUri="/method.xaml?type=math&amp;detail=good" />,在method.xaml.cs中,代码如下:        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (NavigationContext.QueryString.Count != 0)
            {
                this.txtPageTitle.Text = NavigationContext.QueryString["type"];
                this.txtBlockMethod.Text = NavigationContext.QueryString["detail"];
            }

        }


运行,OK……