原創|使用教程|編輯:我只采一朵|2016-04-05 11:28:34.000|閱讀 1727 次
概述:本文檔講解如何自動或手動添加 DXSplashScreen 加載控件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
你也可以 下載Universal安裝包 或者到 查看更多示例和教程
DevExpress WPF 的 DXSplashScreen 控件在應用加載的時候顯示一個啟動界面。添加DXSplashScreen后,會默認生成一個XAML文件,當然,你也可以根據自己的需求自定義XAML文件。
1.右鍵單擊 Solution Explorer 中的項目,并選擇 Add DevExpress Item | New Item..
2.在彈出的 DevExpress Template Gallery 中單擊 DXSplashScreen 項目。
添加DXSplashScreen后,會生成一個XAML文件。如果想自定義加載界面,修改XAML文件即可。
DXSplashScreen可以在窗口加載時自動調用,然后在窗口初始化完畢后自動關閉,要實現這個功能,只需要在主窗口的XAML文件添加如下代碼:
dxc:DXSplashScreen.SplashScreenType="{x:Type local:SplashScreenWindow1}"
dxc 和 local聲明如下:
xmlns:local="clr-namespace:WpfApplication7" xmlns:dxc="//schemas.devexpress.com/winfx/2008/xaml/core"
但是這樣做有個缺陷就是無法控制進度條的進程,要控制進程,就要用另一種方式:手動調用DXSplashScreen。
你也可以手動控制合適顯示和隱藏DXSplashScreen控件,這要通過DXSplashScreen類的一個靜態方法來實現。
舉個例子,下面的代碼打開看一個應用程序的加載界面:
下面的代碼關閉加載界面:
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(); } } }
默認情況下,DXSplashScreen包含一個進度條,表示應用程序加載的進度,下面的代碼就可以實現手動控制進度:
// 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>(); } } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn