C# WPF 标签和滚动条不会更新



我有一段代码:

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

我遇到的问题是label_ppitch会刷新,而label_yaw不会。Label_yaw每15毫秒获得一个新值,但即使提供了该值,标签本身也不会更新。

有人有解决方案吗?

Dispatcher.Invoke需要委托,仅提供签名没有帮助。

使用这个

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

最新更新