Delay custom render control rendering in WPF

I have a custom WPF control that sometimes takes some time to render in some complex scenarios. I would like my user control to display a placeholder image (for example, "Please wait - rendering!"), And then actually display the control in standby mode (after processing the input).

I think that my user control has been modified to store the parent grid and two child elements: A) the placeholder image and B) the actual content. By default A) is visible, and when the visibility of user control changes I could have a BeginInvoke delegate, which, in turn, showed B) instead of A).

If there are many / several such control instances on the screen, they hopefully will not block the main thread while rendering all of them at the same time. Because delegates are queued with a priority lower than the input priority, the user interface should theoretically remain very responsive.

Has anyone encountered a similar problem?

+3
source share
1 answer

Yes, this approach will work fine, and I have used it several times.

, , / . , Dispatcher.

. , DP - Revision int AffectsRender. , , BeginInvoke(), Revision, . OnRender, .

+1

Source: https://habr.com/ru/post/1733240/


All Articles