原創(chuàng)|使用教程|編輯:我只采一朵|2016-04-05 11:28:34.000|閱讀 1727 次
概述:本文檔講解如何自動(dòng)或手動(dòng)添加 DXSplashScreen 加載控件。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
你也可以 下載Universal安裝包 或者到 查看更多示例和教程
DevExpress WPF 的 DXSplashScreen 控件在應(yīng)用加載的時(shí)候顯示一個(gè)啟動(dòng)界面。添加DXSplashScreen后,會(huì)默認(rèn)生成一個(gè)XAML文件,當(dāng)然,你也可以根據(jù)自己的需求自定義XAML文件。
1.右鍵單擊 Solution Explorer 中的項(xiàng)目,并選擇 Add DevExpress Item | New Item..
2.在彈出的 DevExpress Template Gallery 中單擊 DXSplashScreen 項(xiàng)目。
添加DXSplashScreen后,會(huì)生成一個(gè)XAML文件。如果想自定義加載界面,修改XAML文件即可。
DXSplashScreen可以在窗口加載時(shí)自動(dòng)調(diào)用,然后在窗口初始化完畢后自動(dòng)關(guān)閉,要實(shí)現(xiàn)這個(gè)功能,只需要在主窗口的XAML文件添加如下代碼:
dxc:DXSplashScreen.SplashScreenType="{x:Type local:SplashScreenWindow1}"
dxc 和 local聲明如下:
xmlns:local="clr-namespace:WpfApplication7" xmlns:dxc="//schemas.devexpress.com/winfx/2008/xaml/core"
但是這樣做有個(gè)缺陷就是無法控制進(jìn)度條的進(jìn)程,要控制進(jìn)程,就要用另一種方式:手動(dòng)調(diào)用DXSplashScreen。
你也可以手動(dòng)控制合適顯示和隱藏DXSplashScreen控件,這要通過DXSplashScreen類的一個(gè)靜態(tài)方法來實(shí)現(xiàn)。
舉個(gè)例子,下面的代碼打開看一個(gè)應(yīng)用程序的加載界面:
下面的代碼關(guān)閉加載界面:
using DevExpress.Xpf.Core; namespace WpfApplication7 { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainWindow_Loaded); } void MainWindow_Loaded(object sender, RoutedEventArgs e) { DXSplashScreen.Close(); this.Activate(); } } }
默認(rèn)情況下,DXSplashScreen包含一個(gè)進(jìn)度條,表示應(yīng)用程序加載的進(jìn)度,下面的代碼就可以實(shí)現(xiàn)手動(dòng)控制進(jìn)度:
// Developer Express Code Central Example: // How to manually invoke and close DXSplashScreen // // This example shows how to manually invoke and close DXSplashScreen. By default, // DXSplashScreen contains a progress bar, indicating the progress of the // application load. This example also shows how you can manually change the // progress in code. // // You can find sample updates and versions for different programming languages here: // //www.devexpress.com/example=E3243 using DevExpress.Xpf.Core; using System.Windows; namespace DXSplashScreenSample { public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); DXSplashScreen.Show<SplashScreenView>(); } } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn