如何更改WPF中不确定进度栏动画的速度和宽度?
关于WPF进度栏,当issindetermination设置为True时,我个人认为动画太快了。
我认为减慢动画的速度,也许使内部栏更宽会有助于缓解这个问题。
无论如何是否可以自定义?
编辑:添加代码
.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);
}
}
}
Regarding the WPF Progress Bar when IsIndeterminate is set to true, I personally think the animation is too fast.
I think slowing the animation down and maybe making the internal bar wider would help ease this problem.
Is there anyway to customize this?
edit: added code
.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);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过编辑
Visual Statate
命名不确定的动画来自定义不确定的动画。以下是VistalState
在progressbar
的当前默认样式中。分别更改第二和第三
keytime
以更改动画速度。进一步的自定义取决于您。You can customize the Indeterminate animation by editing
VisualState
named Indeterminate. The following is thatVistalState
in current default Style ofProgressBar
.Change 2nd and 3rd
KeyTime
respectively to change the speed of animation. Further customization is up to you.