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()
查看全文
  • 相关阅读:
    面试题47题
    深度学习面试
    神经网络训练中的梯度消失与梯度爆炸
    Softmax函数与交叉熵
    sourceTree 添加 ssh key 方法
    request.form()和request()的区别
    C#中Request.ServerVariables详细说明及代理
    Page_Load事件与IsPostBack属性
    CSS中position的absolute和relative用法
    读取游标
  • 原文地址:https://www.cnblogs.com/024hi/p/1345205.html
  • Copyright © 2011-2022 走看看