Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - SetWindowRedraw equivalent in WPF?

 
 
Old 11-09-2006   #1 (permalink)
John Dunn


 
 

SetWindowRedraw equivalent in WPF?

Is there a way to temporarily stop updates when adding a large number of
visual objects to a Canvas? On certain event I'm programatically
adding a bunch of DrawingVisuals to my Canvas and I think it would make
sense to stop the Canvas from updating the view until I'm done. Not only
would it probably be faster but right now the graphics randomly pop into
view which I think would be disconcerting to the user.

I have a custom implementation of VisualChildren ( overriding
VisualChildrenCount and GetVisualChild ) if that matters.

In Win32 you could call SetWindowRedraw when adding a bunch of items to
a control ( ListView, TreeView, etc ) to help with performance issues.
Is there something similar in WPF? I looked through the SDK and didn't
see anything obvious.

Thanks-

John

My System SpecsSystem Spec
Old 11-10-2006   #2 (permalink)
Bob


 
 

Re: SetWindowRedraw equivalent in WPF?

In article <OdoFIACBHHA.3316@TK2MSFTNGP02.phx.gbl>,
jhndnn@community.nospam says...
> Is there a way to temporarily stop updates when adding a large number of
> visual objects to a Canvas? On certain event I'm programatically
> adding a bunch of DrawingVisuals to my Canvas and I think it would make
> sense to stop the Canvas from updating the view until I'm done. Not only
> would it probably be faster but right now the graphics randomly pop into
> view which I think would be disconcerting to the user.
>
> I have a custom implementation of VisualChildren ( overriding
> VisualChildrenCount and GetVisualChild ) if that matters.
>
> In Win32 you could call SetWindowRedraw when adding a bunch of items to
> a control ( ListView, TreeView, etc ) to help with performance issues.
> Is there something similar in WPF? I looked through the SDK and didn't
> see anything obvious.
>
> Thanks-
>
> John
>


John,
Have a look at FrameworkContentElement.BeginInit and EndInit methods.
My System SpecsSystem Spec
Old 11-10-2006   #3 (permalink)
John Dunn


 
 

Re: SetWindowRedraw equivalent in WPF?

Bob wrote:
> In article <OdoFIACBHHA.3316@TK2MSFTNGP02.phx.gbl>,
>
> John,
> Have a look at FrameworkContentElement.BeginInit and EndInit methods.


Bob-

Thanks for the reply. Unless I'm misreading the documentation, that
doesn't look like what I need. From reading the SDK it sounds like
BeginInit/EndInit are called during the initialization stage of a
FrameworkContentElement. I assume that would be the place to add a bunch
of children while my panel was initializing.

The problem is that I'm adding content at runtime, not during
initialization. My canvas is already created and visible with some
content, and the user will come along and do something that will cause
more or less content to appear. Ideally I'd like something like this

// stop the canvas from redrawing when children are
addedcanvas->LockUpdates();
//
// add a bunch of children to the canvas
//
// allow the canvas to process updated children
canvas->UnLockUpdates();

Thanks-

John

My System SpecsSystem Spec
Old 11-10-2006   #4 (permalink)
John Dunn


 
 

Re: SetWindowRedraw equivalent in WPF?

Let my repost that pseudo code since it looks like Thunderbird decided
to format it for me.

// stop the canvas from redrawing when children are

addedcanvas->LockUpdates();

//
// add a bunch of children to the canvas
//


// allow the canvas to process updated children

canvas->UnLockUpdates();
My System SpecsSystem Spec
Old 11-10-2006   #5 (permalink)
Laurent Bugnion


 
 

Re: SetWindowRedraw equivalent in WPF?

Hi,

John Dunn wrote:
> Thanks for the reply. Unless I'm misreading the documentation, that
> doesn't look like what I need. From reading the SDK it sounds like
> BeginInit/EndInit are called during the initialization stage of a
> FrameworkContentElement. I assume that would be the place to add a bunch
> of children while my panel was initializing.
>
> The problem is that I'm adding content at runtime, not during
> initialization. My canvas is already created and visible with some
> content, and the user will come along and do something that will cause
> more or less content to appear. Ideally I'd like something like this
>
> // stop the canvas from redrawing when children are
> addedcanvas->LockUpdates();
> //
> // add a bunch of children to the canvas
> //
> // allow the canvas to process updated children
> canvas->UnLockUpdates();
>
> Thanks-
>
> John


The names are terrible, and the documentation is not clear, but from all
the examples I saw so far, I think that BeginInit and EndInit are
actually exactly doing that: Blocking the update on a
FrameworkContentElement temporarily, while you add stuff to it. After
EndInit is called, the framework will redraw the element.

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
VB6 Equivalent .NET General
how to get pid, equivalent to $$ in unix PowerShell
Is there an equivalent to /dev/null PowerShell
Equivalent to $0? PowerShell
what is the equivalent of xp pro Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46