我使用一些 WPF 双动画来移动StackPanel
.
<Canvas ClipToBounds="True" Name="canMain" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<StackPanel Name="tbmarquee" HorizontalAlignment="Stretch" ></StackPanel>
</Canvas>
每次我使用相同的时间 30 秒,我都会UIElemnts
在StackPanel
. 所以宽度StackPanel
是不同的,它会改变动画速度,就像如果我有很多项目,StackPanel
那么动画非常慢,如果我有 1 个项目,它会非常快。
任何线索我必须使用哪个系数来获得稳定的动画速度?
谢谢!
附言
似乎这段代码或多或少地给出了正确的系数
var coeff = 0;
if (test.Count >= 1 && test.Count <= 10)
coeff = 60;
else if (test.Count > 10 && test.Count <= 20)
coeff = 120;
else if (test.Count > 20 && test.Count <= 30)
coeff = 240;
else if (test.Count > 30 && test.Count <= 40)
coeff = 300;
else if (test.Count > 40 && test.Count <= 50)
coeff = 350;
else if (test.Count > 50 && test.Count <= 60)
coeff = 400;
else if (test.Count > 60 && test.Count <= 70)
coeff = 450;
else if (test.Count > 70 && test.Count <= 80)
coeff = 500;
else if (test.Count > 80 && test.Count <= 90)
coeff = 530;
else if (test.Count > 90 && test.Count <= 100)
coeff = 560;
and etc...
任何线索如何将其转换为某种表达式?