Page view counter
Canvas VS Grid, performance wise
Last post 10-08-2008 11:05 AM by Dave Relyea. 4 replies.
Sort Posts:
10-06-2008 9:04 AM
Canvas VS Grid, performance wise

Is there any informatio on performance of different ways of layout? 

I'm writing an application that displays multiple boxes inside of an invisible grid, I could implement it either with grid, rows & columns, or with stack panels and canvases inside. I would like to know which way would be, or should be, faster when we are talking about hundreds of boxes inside of an invisible grid.

 Thanks

olexiy

Loading...
Joined on 10-22-2007
Posts 20
10-06-2008 9:37 AM
Re: Canvas VS Grid, performance wise

You can try that easily for yourself..

Create a loop and drop several thousands of objects in the container;

measure that with a Stopwatch object..

 

 

avbersSL

Loading...
Joined on 08-10-2008
The Netherlands
Posts 36
10-06-2008 9:42 AM
Re: Canvas VS Grid, performance wise

I'm mostly interested in user interaction and scrolling rather than a time to initialize objects.

Would Stopwatch measure how long it will take from the moment loop is completed till all the objects displayed on a screen and users can use the application. I doubt it.

olexiy

Loading...
Joined on 10-22-2007
Posts 20
10-08-2008 4:15 AM
Marked as Answer
Re: Canvas VS Grid, performance wise

Hello, Grid will of course take longer to perform layout compared with Canvas. But the difference won't be too much unless you have millions of objects. The difference lies in MeasureOverride and ArrangeOverride methods. The Silverlight implementations are written in native code. But you can use Reflector to view WPF's Grid/Canvas's source to get an idea.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

Yi-Lun Luo - MSFT

Loading...
Joined on 10-29-2007
Posts 2,688
10-08-2008 11:05 AM
Marked as Answer
Re: Canvas VS Grid, performance wise

I believe that you will find that Grid will be fast enough for your purposes, even if you ignore the overhead that you will have to do to set things up the other way.

Grid does a lot but it is very fast. We did test it for scalability and found no problems.

Dave Relyea [MSFT]
http://blogs.msdn.com/devdave

Dave Relyea

Loading...
Joined on 05-09-2007
Posts 245
Microsoft Communities