简体   繁体   中英

Why is ShowGridLines so slow?

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?

The ShowGridLines property is not optimised for runtime as it is intended to be a design time tool only.

From the documentation:

Enabling grid lines creates dotted lines around all the elements within a Grid. Only dotted lines are available because this property is intended as a design tool to debug layout problems and is not intended for use in production quality code. If you want lines inside a Grid, style the elements within the Grid to have borders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM