2016-01-14 25 views
0

我有這樣一段代碼:那我有是label_pitch刷新而label_yaw不C#WPF標籤和滾動條將不會更新

this.Dispatcher.Invoke((Action)(() => 
           { 
            label_pitch.Content = _pitch.ToString(); 
            scrPitch.Value = _pitch; 

            label_yaw.Content = _yaw.ToString(); 
            scrYaw.Value = _yaw; 
            ... 
           })); 

問題。 Label_yaw每15毫秒獲取一個新值,但即使提供,標籤本身也不會更新。

有人有解決方案嗎?

回答

0

Dispatcher.Invoke需要委託,只是提供簽名將無濟於事。

使用此。

Dispatcher.Invoke(new Action(() => 
{ 
    label_pitch.Content = _pitch.ToString(); 
    scrPitch.Value = _pitch; 
    label_yaw.Content = _yaw.ToString(); 
    scrYaw.Value = _yaw; 
}));