WPF中Application.Current的使用

來源:互聯網
上載者:User

標籤:ati   ica   調用   source   資源   cat   col   程式   exp   

原文:WPF中Application.Current的使用

WPF程式對應一個Application對象,當前的Application對象可以通過Application.Current擷取,通過擷取到的Application對象,我們可以做以下的事情:

Application.Current.FindResource("資源名");//擷取程式中定義的資源Application.Current.MainWindow;//擷取程式中定義的主表單Application.Current.Properties["MyProperty"];//擷取或設定應用範圍的屬性Application.Current.Shutdown();//終止當前程式Application.Current.ShutdownMode = ShutdownMode.OnLastWindowClose ;//設定程式關閉的方式//OnLastWindowClose —— 最後一個表單關閉時關閉程式//OnMainWindowClose —— 主表單關閉時關閉程式//OnExplicitShutdown —— 需要顯示調用Application.Current.Shutdown()去關閉程式,否則程式將在後台繼續運行Application.Current.Windows;//擷取程式中啟動並執行所有表單//一般主表單會是第一個啟動並執行表單,因此此時Application.Current.Windows[0]等同於Application.Current.MainWindow

 

WPF中Application.Current的使用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.