新的Telerik UI。net MAUI?开始30天的免费试用

.NET MAUI BusyIndicator中的动画

BusyIndicator提供了用于控制其内置动画的大小和颜色的选项,并允许您定义自定义动画。

内置的动画

要更改BusyIndicator的选定动画,请使用其AnimationType财产。AnimationType是否接受来自的值的enumAnimation1Animation10.默认情况下,AnimationType设置为Animation1

动画只会在IsBusy属性设置为真正的

BusyIndicator动画列表

控制尺寸和颜色

要更改动画元素(动画内容)的大小和颜色,请使用以下属性:

  • AnimationContentWidthRequest而且AnimationContentHeightRequest-定义动画大小。
  • AnimationColor自定义内置动画的颜色。

AnimationContentWidthRequestAnimationContentHeightRequest,AnimationColor如果你使用自定义动画将不会被应用。

默认情况下,动画内容的大小是25x25像素。

下面的代码片段展示了如何配置预定义的BusyIndicator动画。

  

下图显示了修改后的BusyIndicator处于繁忙状态。

BusyIndicator设置

自定义动画

属性的组合可创建自定义动画AnimationTypeBusyContent,动画属性:

  1. 控件要指示控件使用自定义动画,请设置AnimationType自定义

  2. 添加您想要动画的内容BusyContent

  3. 自定义动画被添加到动画BusyIndicator的集合。

下面的例子演示了如何在XAML中创建一个自定义动画来改变文本的不透明度(闪烁效果)。

  
RadDoubleAnimation动画=新的RadDoubleAnimation(){持续时间= 800,From = 0.1, To = 1, PropertyPath = "不透明度",目标= radBusyIndicator。BusyContent, RepeatForever = true, AutoReverse = true};this.radBusyIndicator.Animations.Add (annimation);Device.StartTimer(TimeSpan.FromMilliseconds(5000), () => {this.radBusyIndicator.IsBusy = false;返回错误;});

下面的示例演示如何创建一个自定义动画,该动画在代码隐藏中更改文本的不透明度(闪烁效果)。

RadBusyIndicator RadBusyIndicator = new RadBusyIndicator() {IsBusy = true, AnimationType = AnimationType。自定义,Content = new Label() { Text = "This is the content of the RadBusyIndicator control displayed when the indicator is not busy." }, BusyContent = new Label() { Text = "Loading...", VerticalOptions = new LayoutOptions(LayoutAlignment.Center, false), HorizontalOptions = new LayoutOptions(LayoutAlignment.Center, false), }, }; RadDoubleAnimation annimation = new RadDoubleAnimation() { Duration = 800, From = 0.1, To = 1, PropertyPath = "Opacity", Target = radBusyIndicator.BusyContent, RepeatForever = true, AutoReverse = true }; radBusyIndicator.Animations.Add(annimation); Device.StartTimer(TimeSpan.FromMilliseconds(5000), () => { radBusyIndicator.IsBusy = false; return false; });

另请参阅

在本文中
找不到你需要的帮助?
Baidu
map