I would like to find the fastest way to tell if a grid row has been painted. I am currently calling the GetUIElement on the row in the InitializeRow event and my profiler tool is saying that is taking a very long time. I tried the GetType method and it is much faster, but I am looking for a best practice. I do not want to force the row to be painted. I just want to see if it has ever been painted.
GetUIElement does a linear walk through all of the grid's UIElements, hence the less-than-optimal performance.
I attached a sample that uses the IUIElementCreationFilter interface to track the creation of RowUIElements.
Note that I assume we are considering "painted" and "has a UIElement" to be logically equivalent for the purposes of this problem; a control's UIElements can be generated independently of a paint operation so I just want to clarify that point.
Thanks, Brian, I'll give this a try.