Events fired when you change the contents of a control in Silverlight

Posted by nyxtom on Stack Overflow See other posts from Stack Overflow or by nyxtom
Published on 2010-03-12T10:46:16Z Indexed on 2010/03/12 10:47 UTC
Read the original article Hit count: 166

Assuming I change the contents of a control using a XamlReader and add the UIElement to the container of a control, what events are supposed to fire? There are times where the SizeChanged will fire, LayoutUpdated changing.. though there are other times where neither of these occur despite having changing the contents of a control.

In my case, I am generating a thumbnail view of what's currently in view on a page. The user can change the content of the page and thus the thumbnail should update accordingly. Though, wiring to the LayoutUpdated, Loaded, SizeChanged aren't always reliable for when the contents have changed.

I would just call my InvalidateThumbnail which uses a writeablebitmap, but it's too quick after setting the content and as a result I will get a blank thumbnail.

At the moment, my hack (cringes) was to wait a few milliseconds before the UI is done rendering the actual new content and I can reliably create the thumbnail. I'd rather just trigger on an event every time though.

Possible? What events should I look at? I've seen CompositeTarget.Rendering but that's not what I want.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about c#