I have some code which renders the contents of a Canvas to a bitmap. Periodically, child elements of the Canvas can change visually and I need a way of discerning when this has happened so that I can re-draw the Bitmap. My initial idea was to override Canvas.OnRender but this doesn’t seem to get called when a child re-renders.
Any advice would be much appreciated
Remember that WPF is not redrawn on a frame base, but more on the concept of dirty regions. Also OnRender is not like OnPaint, its used to create a cached representation to render the actual content, in most cases its not necessary to re-render to display some changes, thats why its not called. To get the effect you want, you could use the CompositionTarget.Rendering event. Its propably the closest you can get to a paint event.
But one warning, the moment you attach to that event, the rendering behavior changes a bit check this.
Another idea might be to look into VisualBrush.