views:

22

answers:

2

Is there a way to get notified (e.g., by an event) when a Visual has been (re-)rendered?

Basically, I would like to take a screen shot whenever a Visual's appearance has changed. I assume the rendering thread is taking care of this in the background.

I am trying to avoid grabbing a screen shot periodically since I am only interested in changes (e.g., hovering the cursor over a button would change its appearance).

Any hint is highly appreciated!

+1  A: 

This MSDN thread provides quite a bit of information on the subject. Basically it doesn't really work that way and you'll find the exact reasons there.

Alex Paven
A: 

This is not possible in WPF. Your best bet would be to take a snapshot in memory frequently and compare it with the previous. If you detect a diffrence, persist the snapshot. You could use the CompositionTarget.Rendering event for this. Just make sure that you don't take a snapshot in each event (since it is called as freuqently as the graphics card swaps its buffer).

bitbonk