3

I have noticed that enabling ShowGridLines on a Grid causes a huge performance hit.

I have a Grid within a ScrollViewer. When I scroll manually, the application runs fine. However, if I scroll programmatically, using a timer to scroll smoothly, it runs very slow with ShowGridLines on.

With ShowGridLines off, the scrolling completes in less than 1/2 a second as expected. With ShowGridLines on, the scrolling takes 2-5 seconds and jerks unpredictably.

Why would ShowGridLines cause such a performance penalty? Why would it not do so when scrolling manually? Is there a way around this?

4

1 回答 1

6

ShowGridLines属性未针对运行时进行优化,因为它仅用作设计时工具。

从文档中:

启用网格线会在网格内的所有元素周围创建虚线。只有虚线可用,因为此属性旨在用作调试布局问题的设计工具,而不是用于生产质量代码。如果您想要网格内的线条,请将网格内的元素设置为具有边框。

于 2013-07-13T20:05:25.867 回答