我在 WPF 的 for 循环中更新画布时遇到问题。在我的应用程序中,我有来自很多帧的 Stickfigures 的数据,我想绘制 2 个彼此相邻的不同录音的 Stickfigures。我知道绘图功能有效,但我无法让我的代码不断更新画布。我只能看到最后一帧的简笔画。我知道对于其他帧,正在计算简笔画,但它们没有显示在画布上。
我使用折线函数绘制简笔画。
这是我使用的 for 循环。
for (int i = 0; i < recording1.Count; i++)
{
skeletCanvas1.Children.Clear();
skeletCanvas2.Children.Clear();
skeletCanvas1.Children.Add(drawLine(points1((double[])recording1[i]), brush1));
skeletCanvas1.Children.Add(drawLine(points2((double[])recording1[i]), brush1));
skeletCanvas1.Children.Add(drawLine(points3((double[])recording1[i]), brush1));
skeletCanvas1.Children.Add(drawLine(points4((double[])recording1[i]), brush1));
skeletCanvas1.Children.Add(drawLine(points5((double[])recording1[i]), brush1));
skeletCanvas2.Children.Add(drawLine(points1((double[])recording2[i]), brush2));
skeletCanvas2.Children.Add(drawLine(points2((double[])recording2[i]), brush2));
skeletCanvas2.Children.Add(drawLine(points3((double[])recording2[i]), brush2));
skeletCanvas2.Children.Add(drawLine(points4((double[])recording2[i]), brush2));
skeletCanvas2.Children.Add(drawLine(points5((double[])recording2[i]), brush2));
skeletCanvas1.UpdateLayout();
skeletCanvas2.UpdateLayout();
System.Threading.Thread.Sleep(100);
}
谢谢你的帮助。