HighTechTalks DotNet Forums  

Scrolling large WPF custom panel

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss Scrolling large WPF custom panel in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Sven at Mercur
 
Posts: n/a

Default Scrolling large WPF custom panel - 09-13-2007 , 05:18 AM






I have created a custom "panel" (it doesn't actually inherit from Panel). It
is a kind of grid which needs to be scrolled both horizontally and
vertically, and since it can contain a large number of elements, it needs to
be virtualizing.

I did this by inheriting from FramworkElement, implementing IScrollInfo and
overriding GetVisualChildren as well as MeasureOverride/ArrangeOverride. As
it scrolls, new elements are added and removed in MeasureOverride. (I use
transforms for short scrolls by generating a margin of realized element
outside the displayed area, but that is not relevant to this issue.)

However, performance is terrible when scrolling page-wise or when dragging
the thumb of a scrollbar. It takes around 0.3 seconds to get a new screen,
which is around 5 times slower than what I would consider acceptable.

I have created a simplistic example displaying the same problem (although
the details are not exactly as described above, for example the realization
code is not inside MeasureOverride, but rather in the IScrollInfo methods
instead). It is available at ftp://ftp.mercur.se/pub/Misc/ScrollProblem.zip
(I zipped the entire folder containing a VS2005 solution).

Platform is an up-to-date .NET 3.0 on Windows XP SP2.

So, what can I do to get reasonable performance for this type of problem?

Reply With Quote
  #2  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: Scrolling large WPF custom panel - 09-14-2007 , 03:03 AM






Hi Sven,

Welcome to MSDN Managed Newsgroup!

Based on my understanding, you actually want to build a panel that supports
"virtual mode". I think WPF actually has a dedicated class can help you
that, it's called VirtualizingStackPanel.

Here's some examples on it:

#Dan Crevier's Blog : Implementing a virtualized panel in WPF (Avalon)
http://blogs.msdn.com/dancre/archive...06/526310.aspx

#Dan Crevier's Blog : Implementing a VirtualizingPanel part 2:
IItemContainerGenerator
http://blogs.msdn.com/dancre/archive...13/531550.aspx

#Dan Crevier's Blog : Implementing a VirtualizingPanel part 3: MeasureCore
http://blogs.msdn.com/dancre/archive...14/532333.aspx

#Dan Crevier's Blog : Implementing a VirtualizingPanel part 4: the goods!
http://blogs.msdn.com/dancre/archive...16/533870.aspx


Please feel free to let me know if you need anything. Thanks.


Sincerely,
Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #3  
Old   
Sven at Mercur
 
Posts: n/a

Default RE: Scrolling large WPF custom panel - 09-14-2007 , 06:26 AM



Hi Walter,

""Walter Wang [MSFT]"" wrote:

Quote:
Based on my understanding, you actually want to build a panel that supports
"virtual mode". I think WPF actually has a dedicated class can help you
that, it's called VirtualizingStackPanel.
Yes, I do want something rather similar. However, the catch is that it isn't
really a StackPanel I want a virtualizing version of, but rather something
similar to a Grid.

For the simple example I put on the ftp, I guess I could make it work by
having a vertically scrolling virtualizing panel populated by a bunch of
horizontally scrolling virtualizing panels or such.

However, in the real case I'm trying to solve, I also have elements spanning
multiple cells in the grid, horizontally, vertically, or both. I guess this
could be solved with clever use of grids inside the virtualizing panels
inside the virtualizing panels, but that seems like a very hard road to
travel.

Any idea why the simpler solution I tried is so slow, or any other ideas?

Sven (posting alias VisualMercur (AT) nospam (DOT) nospam)



Reply With Quote
  #4  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: Scrolling large WPF custom panel - 09-18-2007 , 02:44 AM



Hi Sven,

Sorry for late reply.

I sent out consulting mail in our internal discussion list last Friday when
I saw your reply, and I'm still waiting for responses.

In the meanwhile, I'm also using Reflector
(http://www.aisto.com/roeder/dotnet/) to take a look at the
VirtualizingStackPanel's implementation. It seems it's inheriting from an
abstract class VirtualizingPanel and implementing IScrollInfo, just like
your current implementation.

I'll keep you posted when I get further information on this. Thanks for
your patience and understanding.


Regards,
Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #5  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: Scrolling large WPF custom panel - 09-20-2007 , 07:33 AM



Hi Sven,

Thank you for your waiting.

In your code, scrolling the panel will cause over 800 UIelements get
removed and another 800 UIelements added to the control tree. This number
is really out of a possible threshold value that WPF internally could
optimize the control hierarchy's re-organizing. Therefore the performance
issue here seems not possible to overcome.

Some developers suggested if it's possible to simply updating the
UIElements' content instead of removing/adding them again.

Hope this helps.


Regards,
Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #6  
Old   
Sven at Mercur
 
Posts: n/a

Default RE: Scrolling large WPF custom panel - 09-21-2007 , 09:56 AM



Hi Walter,

Thanks for the suggestion. I tried the idea of updating the content of the
components instead, but that is also slow, unfortunately.

Anyway, thanks for your efforts,

Sven

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.