views:

246

answers:

5

I am developing an application using WPF. The app runs full screen, and I need it to resize nicely no matter the monitor resolution. The graphic designer has designed beautiful images for the UI buttons, backgrounds, etc. Using an Illustrator plug-in, all the images have been converted to xaml files. I've added all these images into the application, and they look great. I am also using a lot of Grid layouts so that the screen can resize while still maintain the layout. All of this is displaying as desired, nothing looks stretched when run at a different resolution. However, screen transitions and UI interaction are slow.

I am wondering, is this is due to the heavy use of graphics? Am I using too many Grid layouts? But, I need the Grids so that I can have resolution independence.

The application runs fine on my development machine, but is very noticeably slower on machine with lower performance capabilities. Yeah, this is to be expected, but not to the degree that I'm seeing. My employer insists the application runs smoothly on these lower performance machines.

I've done some profiling of the application and it seem that what takes the most time is the display stuff (though I'm not sure I fully understand how effectively to use a profiler).

If it is the WPF that is causing the slowdown, what can I do to improve this?

+5  A: 

You can drill into which WPF activities are using up time using the Performance Profiling Tools for WPF. Assuming a heavy graphical load is causing the slowdown, this should give you some help as to what might need to be simplified (e.g. layouts) or removed (e.g. bitmap effects (these are a classic perf killer, though I don't want to prejudice your profiling!)).

itowlson
+2  A: 

If it is the WPF that is causing the slowdown

Probably not ;)

It is much more likely that it is your code that causes the slowdown. WPF is powerful, but you have to understand the core concepts to make it work well... You should have a look at this video from a PDC session, it provides lots of advice on how to make your WPF application faster

Thomas Levesque
A: 

WPF performance depends heavily on the quality of the video card in the machine more that the processor/memory. Bad video card = bad WPF performance.

+1  A: 

Well, this is a long shot: when I installed VSTS 2010 (and it uses WPF) it was very slow on a Windows 2008 server with enough CPU/memory, and very fast in a more modest notebook. We managed to disable hardware acceleration and it became notably fast into that machine.

Maybe you do want to try this configuration, as it is very simple: Visual Studio 2010 Beta 2 editor performance fix running on a virtual machine

Rubens Farias
Interesting, never seen DisableHWAcceleration used to speed WPF up before!
itowlson
That made me think too.. but worked on VS2010, I swear =)http://stackoverflow.com/questions/1743525/can-i-and-how-do-i-target-net-4-with-vs-2008/1743556#1743556
Rubens Farias
+1  A: 
  1. Convert your XAML Vector Images of buttons into Transparent PNG Images. Path and Shapes are very heavy to render, calculate and resize. Mostly after deployment, the images never change its better to have them as raster then vector, unless you want to perform smooth animation of changing shape, size or other attributes.

  2. Grids are very costly layout managers as compared to Canvas, DockPanel. You can certainly think of replacing certain grids with DockPanel sometimes, but yes its not an easy fix it requires lot of brainstorming.

  3. Avoid Panel with Single Child. Try to reduce Visual Hierarchy.

  4. Use more of fixed size for buttons and such small elements, if you specify fixed sizes of children, it becomes easy for Panels to do layout processing.

Akash Kava
PNG images wont resize nicely, that's why I've gone with vectors.
Dan Vogel
Plus, how do I develop an app that will adjust the layout to fit the screen resolution unless I rely on Grids?
Dan Vogel
Not all images needs to be in PNG, for example all icons, of buttons or like the one on back/forward buttons of IE, they always remain same even if you resize, such buttons can be converted into PNG. You can use DockPanel instead of grid OR use relative column/row sizes instead of "Auto". If you can show screen of your app a little bit, I can then suggest some better steps.
Akash Kava