LoadingDecorator是一个容器控件用于显示 long-loading 的内容。内容还没加载完成的时候会显示一个加载指示器,加载完成后指示器消失,如下图所示:

DevExpress WPF入门指南:加载动画的应用-LMLPHP

开启LoadingDecorator

用dx:LoadingDecorator标签:

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Views:NavigationView/>
<dx:LoadingDecorator Grid.Column="1">
<Views:MainView/>
</dx:LoadingDecorator>
</Grid>

自定义 Loading Indicator

LoadingDecorator提供了一系列属性,用于自定义Loading Indicator外观。

定义indicator 布局:LoadingDecorator.SplashScreenTemplate 属性;
传递自定义数据:LoadingDecorator.SplashScreenDataContext 属性;
更改加载条位置:LoadingDecorator.SplashScreenLocation 属性;
将加载条在窗口居中或者容器居中:(SplashScreenLocation.CenterWindow) or (SplashScreenLocation.CenterContainer).

<Grid>
...
<dx:LoadingDecorator Grid.Column="1" SplashScreenDataContext="{Binding ... }" SplashScreenLocation="CenterContainer">
<dx:LoadingDecorator.SplashScreenTemplate>
<DataTemplate>
<Grid>
...
</Grid>
</DataTemplate>
</dx:LoadingDecorator.SplashScreenTemplate>
<Views:MainView/>
</dx:LoadingDecorator>
</Grid>

LoadingDecorator.BorderEffect 和 LoadingDecorator.BorderEffectColor 属性可以设置高亮效果。BorderEffect 设置边框高亮,BorderEffectColor 设置边框高亮颜色。

<dx:LoadingDecorator ... BorderEffect="Default" BorderEffectColor="Blue">
...
</dx:LoadingDecorator>

DevExpress WPF入门指南:加载动画的应用-LMLPHP

如果不想要加载条,将 LoadingDecorator.UseFadeEffect 设置 False 即可。

慧都控件网全面开启史上规模最大、折扣最低、力度最疯狂的迎新特惠活动——百厂约惠,时间仅限26天!在此之际,DevExpress率先宣布正式加入百厂约惠活动!

04-16 15:48