How to speed up WPF programs?

后端 未结 8 713
清酒与你
清酒与你 2020-12-12 10:04

I love programming with and for Windows Presentation Framework. Mostly I write browser-like apps using WPF and XAML.

But what really annoys me is the slowness of WPF

相关标签:
8条回答
  • 2020-12-12 10:44

    Install SP1... Loads of very cool performance increases for WPF!!!

    Read more here

    Here is a example of 2 enhanchements made in SP1: Deffered scrolling & UI Element recyceling!!!

    0 讨论(0)
  • 2020-12-12 10:44

    WPF is meant for computers with modern graphics cards. Do your clients have modern graphics cards capable of running Aero? If your clients have older graphics cards, WPF will fall back to software rendering which runs extremely slow in comparison to hardware accelerated graphics.

    You also might want to profile your application to make sure that it is actually WPF that is the slow part. It's possible that there is something else that is actually the bottleneck.

    0 讨论(0)
  • 2020-12-12 10:44

    Remove alpha transparency/ bitmap effects.

    0 讨论(0)
  • 2020-12-12 10:53

    I find it helpful to side-step the XAML, and write the entire UI in C#. This lets me precisely control when the controls are created and loaded. It also helps me understand what XAML is doing "under the covers".

    0 讨论(0)
  • 2020-12-12 10:54

    can you give more details?

    I only noticed a slow performance when I use something like a listview or a grid that has some complexity. The solution is to simplify it.

    Other than that I only noticed a slow performance when loading the app for the first time.

    HTH

    0 讨论(0)
  • 2020-12-12 10:55
    1. How do you speed up WPF?

      Often after using one of the following profiling tools it is obvious what is causing my bottlenecks.

      • If memory is the issue then I virtualize my data.
      • If render time is the issue then I virtualize the controls or simplify control templates where possible.
      • If processing time is the issue I try to improve my algorithm or move that work to a background thread and show a throbber in my ui while the work is going.

    2. How do you profile bottlenecks?

      • .NET Memory Pofiler
      • dotTrace
      • Performance Profiling Tools for WPF
      • Snoop
      • Crack.NET

    3. How do you deal with the slowness?

      Profiling and counseling.

    0 讨论(0)
提交回复
热议问题