DevExpress WPF入门指南:如何自动或手动添加DXSplashScreen控件
2017-12-15 10:46
337 查看
《DevExpress
v17.2 版本更新公开课》点击报名
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 和 local声明如下:
但是这样做有个缺陷就是无法控制进度条的进程,要控制进程,就要用另一种方式:手动调用DXSplashScreen。
你也可以手动控制合适显示和隐藏DXSplashScreen控件,这要通过DXSplashScreen类的一个静态方法来实现。
举个例子,下面的代码打开看一个应用程序的加载界面:
下面的代码关闭加载界面:
默认情况下,DXSplashScreen包含一个进度条,表示应用程序加载的进度,下面的代码就可以实现手动控制进度:
v17.2 版本更新公开课》点击报名
DevExpress WPF 的 DXSplashScreen 控件在应用加载的时候显示一个启动界面。添加DXSplashScreen后,会默认生成一个XAML文件,当然,你也可以根据自己的需求自定义XAML文件。
添加DXSplashScreen到项目中
1.右键单击 Solution Explorer 中的项目,并选择 Add DevExpress Item | New Item..2.在弹出的 DevExpress Template Gallery 中单击 DXSplashScreen 项目。
添加DXSplashScreen后,会生成一个XAML文件。如果想自定义加载界面,修改XAML文件即可。
如何自动调用DXSplashScreen
DXSplashScreen可以在窗口加载时自动调用,然后在窗口初始化完毕后自动关闭,要实现这个功能,只需要在主窗口的XAML文件添加如下代码:dxc:DXSplashScreen.SplashScreenType="{x:Type local:SplashScreenWindow1}"
dxc 和 local声明如下:
xmlns:local="clr-namespace:WpfApplication7" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/core"
但是这样做有个缺陷就是无法控制进度条的进程,要控制进程,就要用另一种方式:手动调用DXSplashScreen。
如何手动调用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: // http://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>(); } } }
相关文章推荐
- DevExpress WPF入门指南:加载动画的应用
- DevExpress WPF入门指南:跟随 Items Source 向导完成数据绑定
- DevExpress WPF入门指南:跟随 Items Source 向导完成数据绑定
- DevExpress WPF入门指南:DXWindow应用
- DevExpress WPF入门指南:Smart Tag扩展功能
- DevExpress WPF入门指南:Smart Tag概述
- DevExpress WPF入门指南:绑定编辑器对话框
- Eclipse新建类的时候如何自动添加注释(作者,时间的信息
- Asp.Net MVC4入门指南(7):给电影表和模型添加新字段
- 在按下添加按钮的时候,如何将光标自动放在datagrid窗格中要添加的新行位置呢 ?
- 如何在Eclipse中如何自动添加注释和自定义注释风格
- Asp.Net MVC4.0 官方教程 入门指南之四--添加一个模型
- 如何在Eclipse中如何自动添加注释和自定义注释风格
- Discuz!论坛教程之如何手动给用户添加数额较大的积分
- oracle 11G GI 如何手动添加vip 资源
- WPF如何后台动态添加控件的右键菜单
- WPF自学教程系列2:如何在xaml文件添加引用?
- 如何给DataGrid添加自动增长列
- 如何在VS2005中自动添加事件处理函数?
- 如何添加一个自动消失的UIAlertView