我上有氣勢面板(用於平滑滾動)的移動應用程序用戶界面的工作進行UI更新和我目前正在更新UI durring通過使用下面的代碼平滑滾動:在一個循環中
private void scrollKinetic()
{
while (_curState == States.KineticScroll)
{
// This gets how far the panel will move with the current velocity, then updates the velocity according to the current friction.
var distY = GetDistance(scrVelocity.Y);
var distX = GetDistance(scrVelocity.X);
if (distY + distX <= 0) // Friction will eventually make distX and distY both 0
{
_curState = States.Idle;
Invalidate();
break;
}
// CalculatePosition will move the panel accordingly.
CalculatePosition(distY, scrVelocity.Y, false);
CalculatePosition(distX, scrVelocity.X, true);
Invalidate();
friction++;
Application.DoEvents();
}
}
正如你所看到的,Application.DoEvents();
正在飼養它的醜陋的頭!我想擺脫它,但我想不出任何方式來循環和更新用戶界面。任何幫助/想法都會很棒!
我在.net CF上這樣做,但我認爲這是一個設計問題,所以我認爲平臺不會太重要。
無法從scrVelocity生成任何事件?然後使用計時器。 – 2011-03-24 04:13:15