Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何重置WPF进度条?_Wpf_Progress Bar_Reset - Fatal编程技术网

如何重置WPF进度条?

如何重置WPF进度条?,wpf,progress-bar,reset,Wpf,Progress Bar,Reset,我正在测试WPF进度条,并试图将其重置为初始状态,但它不起作用 Duration duration = new Duration(TimeSpan.FromSeconds(1)); DoubleAnimation doubleanimation = new DoubleAnimation(200.0, duration); myProgress.IsIndeterminate = true; myProgress.BeginAnimation(ProgressBar.ValueProperty,

我正在测试WPF进度条,并试图将其重置为初始状态,但它不起作用

Duration duration = new Duration(TimeSpan.FromSeconds(1));
DoubleAnimation doubleanimation = new DoubleAnimation(200.0, duration);
myProgress.IsIndeterminate = true;
myProgress.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
myProgress.Value = 0;
动画之前,进度条是静态的(无动画)。 动画完成后,进度条颜色现在为浅灰色(比以前更亮),并具有明亮的闪光效果

在注释持续时间和双动画时,进度条保持静态。我知道这和双重动画有关

//Duration duration = new Duration(TimeSpan.FromSeconds(1));
//DoubleAnimation doubleanimation = new DoubleAnimation(200.0, duration);
myProgress.IsIndeterminate = true;
//myProgress.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
myProgress.Value = 10;
myProgress.Value = 0;

如何解决此问题?我在这里遗漏了什么?

看看这个帖子:


改用这种形式的双重动画

DoubleAnimation doubleanimation = new DoubleAnimation(0,200, duration);
您可以显式地设置from和too值,而不仅仅是目标值

代码:

在窗口中:

myProgress.Maximum = 100; myProgress.Minimum = 0;
然后说在一个按钮点击处理程序

myProgress.IsIndeterminate = false; //shouldn't really need this PB oddity
myProgress.IsIndeterminate = true;
myProgress.Value = 0;

Duration duration = new Duration(TimeSpan.FromSeconds(1));
DoubleAnimation doubleanimation = new DoubleAnimation(0,200, duration);

myProgress.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
PB位于StackPanel中,xaml位于

<ProgressBar Name="myProgress" Height="20"></ProgressBar>

这最初是在XP上测试的,但请参见下文

有关Win 7解决方案,请参见此处


可以,但灰色闪烁辉光效果不会消失。它还在那里。我在复制你所说的辉光效果时遇到了麻烦。您是否在ProgressBar的其他位置设置了其他值?另一件要尝试的事情是在代码中将IsIndeterminate切换为false,然后在下一行将其设置为true,这有帮助吗?我已经上传了视频,您可以在几分钟后看到它。进度条有它的默认值(我没有改变它的属性)。只是在Windows7上试过了-我不喜欢那种发光-看看这篇文章,它似乎解决了这个问题,是的,我在那里。我没有使用情节串连板,只是用c代码来测试这种灰色发光效果是否消失。确实,这是奥什的一个问题。这段视频也有同样的问题