topry
topry

Reputation: 297

Prevent redraw of window when resizing grid row/column

WPF grid container, with multiple rows/columns with usercontrols loaded in the sections.

Some rows/columns are expanded/collapsed by setting the Column/Row width (from 0 to 125* or a fixed value), based upon a button click.

Simple example code:

    If colgrdFolder1.Width.Value Then
        Me.Width = Me.Width - colgrdFolder1.ActualHeight
        colgrdFolder1.Width = New GridLength(0)
    Else
        Me.Width = Me.Width + 150
        colgrdFolder1.Width = New GridLength(150)
    End If

This works, but when the parent resizes, it flashes as the column/row is set. When the parent Width is first increased you can see the grid resize and then when the new colWidth is set, it resizes (and flashes) again.

Is there not a property/method to freeze the window/prevent redraws until the resize is complete?

Upvotes: 1

Views: 532

Answers (1)

Marko
Marko

Reputation: 2365

I think there are BeginInit() and EndInit() methods, that should do what you want (prevent redraw), but in my experience they haven't really worked (maybe I have used them incorrectly).

I don't know of any other way of preventing redraw, perhaps someone who is more of an expert in WPF can shed some more light...

Upvotes: 0

Related Questions