我在多个项目中都遇到过同样的问题,据我所知,这只是一个普通的 ole 错误。这是蹩脚的。我发现的唯一工作是la脚。就像超级,超级跛脚。我希望我有更好的东西,但我没有。无论如何,我发现当我调整网格大小时,这些奇怪的滚动伪影会消失,所以我编写了一些代码来触发引擎更新布局。
Timer _timer;
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
_timer = new Timer(1000);
_timer.Elapsed += _timer_Elapsed;
_timer.Start();
}
void _timer_Elapsed(object sender, ElapsedEventArgs e)
{
//why the hell are we doing this?
//well, the stupid error adorners on the grid like to be mis-aligned
//forcing a layout to happen makes them not look off. lame, I know.
Dispatcher.Invoke(new Action(() =>
{
MainDataGrid.Margin = new Thickness(MainDataGrid.Margin.Left, MainDataGrid.Margin.Top, MainDataGrid.Margin.Right, MainDataGrid.Margin.Bottom + 1);
MainDataGrid.UpdateLayout();
MainDataGrid.Margin = new Thickness(MainDataGrid.Margin.Left, MainDataGrid.Margin.Top, MainDataGrid.Margin.Right, MainDataGrid.Margin.Bottom - 1);
MainDataGrid.UpdateLayout();
}));
}