关于应用启动页的加载

4 篇文章 0 订阅


 

启动页设计要求和思路:

   设计要求:打开应用时,首先加载启动页,在一定时间后跳转到首页,并去除后退按钮再次回到本页。注意:该过程并没有判断应用是否为第一次加载,如需判断,请留言。

   设计思路:在WMAppManifest.xml页面中的导航页设置为启动页。(也可以在xml中设置,个人推荐可视化设置)

操作步骤:

  1.设置你的导航页为启动页:

打开WMAppMainfest.xam

设置启动页为导航页。

2.在你的启动页后台代码中添加应用:using System.Windows.Threading;

输入如下代码:

private DispatcherTimer timer;

        public FirstIn()

        {

            InitializeComponent();

            timer=new DispatcherTimer();

            timer.Interval=new TimeSpan(0,0,0,2);

            timer.Tick += timer_Tick;

            timer.Start();

        }

        void timer_Tick(object sender, EventArgs e)

        {

            //处理事情

            timer.Stop();

            Uri uri=new Uri("/LogoIn.xaml",UriKind.RelativeOrAbsolute);

            NavigationService.Navigate(uri);

            //throw new NotImplementedException();

        }

        //重载导航页面

        protected override void OnNavigatedFrom(NavigationEventArgs e)

        {

            base.OnNavigatedFrom(e);

            PhoneApplicationFrame myframe = Application.Current.RootVisual as PhoneApplicationFrame;

            if (myframe != null)

            {

                try

                {

                    myframe.RemoveBackEntry();

                }

                catch (InvalidOperationException ex)

                {

                    MessageBox.Show(ex.Message);

                    //throw;

                }

            }

        }

 :OnNavigatedFrom事件和OnNavigatedTo的区别

 在本次试用的是OnNavigatedFrom(跳转到其它页面前事件) 事件,因为导航到其他页面后移除返回按钮。(OnNavigatedTo是导航到本页后执行事件)

 3.设计你的导航页面即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值