Saturday, February 5, 2011

Equivalent to SuspendLayout and ResumeLayout in WPF

Specific scenario. ControlA changes a value that causes ControlB (a subclass of scrollviewer) to refigure it's viewport, offset, and extent, and then fire the ScrollableChanged event. ControlB also catches the "ScrollableChanged" event and is programatically scrolled to a determined offset. This creates this awful double redraw that would be completely avoided if i could just call suspendlayout before changing the value and resumelayout after the the calculated scroll is performed.

How do I do this?

  • From here:

    Since layout is done in a separate pass it is implicitly blocked from updating while the UI thread is busy doing something else. Therefore you can add all the controls you want and change all the properties you want and the changes won't take effect until the UI thread returns.

0 comments:

Post a Comment