zoukankan      html  css  js  c++  java
  • [Silverlight]App.Current Events中的Startup,UnhandledException以及Exit事件

    不知道大家注意过没有,我们经常使用Page类中的Loaded()事件处理页面载入后的一些操作,如

    public Page()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(Page_Loaded);
    }
    void Page_Loaded(object sender, RoutedEventArgs e) { }

    但是Page类中却没有Exit()或者Quit()这样的事件,那么我们如何控制当页面被关闭时候应用程序的行为呢?其实我们可以借助App.Current.Exit()事件来实现这个目的。

    public Page()
    {
        InitializeComponent();
        App.Current.Exit += new EventHandler(Current_Exit);
    }
    
    void Current_Exit(object sender, EventArgs e)
    {
        System.Windows.Browser.HtmlPage.Window.Alert("oh on");
    }
    
    
    sshot-1 

    虽然上面的“oh no” 让我写错了。。。是不是很简单呢?

    另外还有两个事件也许会对你有用

  • App.Current.Startup()
  • App.Current.UnhandledException()
查看全文
  • 相关阅读:
    hdu 5170 GTY's math problem(水,,数学,,)
    hdu 5178 pairs(BC第一题,,方法不止一种,,我用lower_bound那种。。。)
    hdu 5179 beautiful number(构造,,,,)
    cf12E Start of the season(构造,,,)
    cf12D Ball(MAP,排序,贪心思想)
    cf 12C Fruits(贪心【简单数学】)
    cf 12B Correct Solution?(贪心)
    hdu 5171 GTY's birthday gift(数学,矩阵快速幂)
    hdu 5172 GTY's gay friends(线段树最值)
    cf 11D A Simple Task(状压DP)
  • 原文地址:https://www.cnblogs.com/024hi/p/1345205.html
  • Copyright © 2011-2022 走看看