关于IsIndeterminate设置为true时的WPF进度条,我个人认为动画太快了。
我认为放慢动画的速度,也许使内部栏更宽将有助于缓解这个问题。
是否可以自定义此选项?
编辑:添加的代码
.xaml格式
<Window x:Class="IndeterminateProgressBarTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:IndeterminateProgressBarTest"
mc:Ignorable="d"
Title="MainWindow" Height="100" Width="700">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="Type">
<VisualState Name="Indeterminate">
<Storyboard RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Animation" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames Storyboard.TargetName="Animation" Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)">
<EasingPointKeyFrame KeyTime="0" Value="0,0"/>
<EasingPointKeyFrame KeyTime="0:0:0" Value="0,0"/>
<EasingPointKeyFrame KeyTime="1:0:0" Value="0,0"/>
</PointAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ProgressBar Name="progressBar" Width="600" Height="25" IsIndeterminate="True"/>
</Grid>
</Window>
.cs格式
namespace IndeterminateProgressBarTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
VisualStateManager.GoToElementState(progressBar, "Indeterminate", true);
}
}
}
1条答案
按热度按时间oipij1gg1#
您可以通过编辑名为Indeterminate的
VisualState
来自定义Indeterminate动画。以下是VistalState
在当前默认样式ProgressBar
中的动画。分别更改2nd和3rd
KeyTime
以更改动画的速度。进一步的自定义由您决定。