Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.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
C# 如何在停止/播放动画中的特定位置启动progressbar?[沙马林表格]_C#_Xamarin_Xamarin.forms - Fatal编程技术网

C# 如何在停止/播放动画中的特定位置启动progressbar?[沙马林表格]

C# 如何在停止/播放动画中的特定位置启动progressbar?[沙马林表格],c#,xamarin,xamarin.forms,C#,Xamarin,Xamarin.forms,这就是我用来阻止progressbar正常工作的方法 progressBar.Animate("SetProgress", (arg) => { System.Diagnostics.Debug.WriteLine(arg); // 0.00 - 1.00 is the value progressBar.Progress = arg; }, 1, 5000, Easing.Linear, (v, c) => progressBar.Progress = 0

这就是我用来阻止progressbar正常工作的方法

progressBar.Animate("SetProgress", (arg) => {

     System.Diagnostics.Debug.WriteLine(arg); // 0.00 - 1.00 is the value
     progressBar.Progress = arg;

}, 1, 5000, Easing.Linear, 
(v, c) => progressBar.Progress = 0);  // when finished, reset
因此,每次制作动画时,progressbar都从0开始。现在我想从某个时间开始。比如说,从500毫秒5秒中的第二个3秒开始

然后我这样做,progressBar.Progress=0.3;在动画上方。无论哪种方式,progressbar仍然从0秒开始


如何在设定的5秒时间内启动计时器?

尝试这样设置动画的初始值

progressBar.AbortAnimation("SetProgress");
取消

var animation = new Animation (v => progressBar.Progress = v, 0.3, 1);

animation.Commit (this, "SimpleAnimation", 16, 2000, Easing.Linear, (v, c) => image.Scale = 1, () => false);

可以使用自定义动画:

this.AbortAnimation ("SimpleAnimation");

如何停止此动画?
double totalTime = 5000;
double startTime = 3000;
var animation = new Animation(v => progress.Progress = v, startTime/totalTime, 1, Easing.Linear);
animation.Commit(this, "LinearProgressFromTime", 16, (uint)(totalTime - startTime) , Easing.Linear, (v, c) => progress.Progress = 1, () => false);