WP7 页面事件触发顺序测试

1、进入页面时

OnNavigatedTo-Loaded

2、离开页面时
OnNavigationFrom
OnNavigatedFrom
UnLoaded

 

总结:

OnNavigatedTo→ Loaded→ OnNavigationFrom→ OnNavigatedFrom→ UnLoaded

 

后台代码:

public partial class About : PhoneApplicationPage
    {
        public About()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(About_Loaded);
            this.Unloaded += new RoutedEventHandler(About_Unloaded);
        }

        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
                base.OnNavigatedFrom(e);
                MessageBox.Show("我是OnNavigatedFrom");
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
               base.OnNavigatedTo(e);
               MessageBox.Show("我是OnNavigatedTo");
        }

        protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
        {
            base.OnNavigatingFrom(e);
            MessageBox.Show("我是OnNavigatingFrom");
        }

        void About_Unloaded(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("我是About_Unloaded");
        }

        void About_Loaded(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("我是loaded");
            //throw new NotImplementedException();
        }
    }

转载于:https://www.cnblogs.com/walleyekneel/archive/2012/03/25/2417249.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值