使UI渲染更快 [英] Make UI rendering faster

查看:88
本文介绍了使UI渲染更快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我们的应用程序中,我们使用3000个控件.这些控件是WPF控件和用户控件的组合(修改后的文本框为spinbutton).

In our application, we use 3000 controls. The controls are a combination of WPF controls and User controls(modified textbox for a spinbutton).

所有这些控件都是在运行时以编程方式添加的.加载GUI需要一分钟.

All these controls are added programmatically at Run time. It takes a minute to load the GUI.

有什么方法可以提高渲染速度?

Is there any way of improving the rendering speed?

谢谢


推荐答案


Viknesh Ramm,您好,


Hi Viknesh Ramm,

我们真的无法提供解决方案,因为我们对您的应用一无所知.

We can’t really give a solution as we know nothing about your app.

大量控件"与绘图性能成反比,通常,几乎使用任何框架,都无法优雅地处理大量控件.
 
您可以做很多事情来帮助您,但是总的来说,唯一真正的解决方案是使用更小的窗口和更少的控件.从可用性的角度来看,这通常会更好.

Large number of controls" is inversely proportional to drawing performance, in general, using nearly any framework, does not handle large numbers of controls gracefully.
 
There are many things you can do to help, but in general, the only real solution is to have smaller windows with fewer controls.  From a usability standpoint, this is usually better anyways.

WPF不会为每个控件使用单独的窗口句柄-整个窗口只使用一个句柄,然后在该窗口中分别渲染每个控件.这使它可以通过数百个(甚至数千个)控件具有非常好的性能.如果您真的必须 这么多的控​​件,我建议您尝试使用更多的窗口,其中每个窗口具有较少的控件.不太好,一次只能在屏幕上显示很多信息.

WPF doesn't use a separate window handle per control - just one for the entire window, then renders each control separately in that window. This allows it to have very good performance with hundreds (or even thousands) of controls. If you really must have this many controls, I suggest you try to have more windows, where each window has a fewer number of controls. Not so good have so much info on the screen at one time.

WPF应用程序的性能与硬件成正比,因此,在没有图形加速设备的计算机上运行的WPF应用程序缓慢地成为公共秘密.除了改善硬件配置外,我们来看一些 改善WPF性能的软方法.这里只是几点,实际上您可以在互联网上找到很多东西.

WPF application performance is proportional to hardware , WPF application running on a machine that does not have a graphics acceleration device is slow to be a public secret. In addition to improving the hardware configuration, let's take a look at some soft ways to improve WPF performance. Here are just a few points, in fact you can find a lot on internet.

1.当WPF程序包含动画时,可以使用

1. When your WPF program contains animations, you can use the BitmapScalingMode property of the RenderOptions object to reduce resource consumption. You need to set the value of the BitMapScalingMode property to LowQuality, which will use the acceleration algorithm to process the image instead of the default high quality image weight Sampling algorithm.

2. Having unnecessary elements in the visual tree also reduces the speed of the WPF program, When building a logical tree or visual tree, follow the Top-Down principle.

3.更多地使用静态资源.请参阅: XAML资源

4.要显示大数据时,请使用UI虚拟化控件.请参阅:优化性能:控件

5.因为可滚动的DataGrid或ListBox将在滚动时强制进行连续更新,这是默认行为,并且它们会降低整个应用程序的性能.在这种情况下,我们可以使用 控制以增强用户体验.您需要做的就是将IsDeferredScrollingEnabled附加属性设置为True.

3. More use of static resources. See : XAML Resources

4. When you want to display large data, use UI virtualization controls. See : Optimizing Performance: Controls

5. Because the scrollable DataGrid or ListBox will force continuous updates when scrolling, which is the default behavior, and they tend to degrade the performance of the entire application. In this case, we can use the Deferred Scrolling property of the control to enhance user experience. All you need to do is set the IsDeferredScrollingEnabled additional property to True.

6.尝试使用WPF 表演套件分析WPF应用程序的运行时行为并确定可以应用的性能优化.  

6. Try to use WPF Performance Suite  to analyze the run-time behavior of your WPF applications and determine performance optimizations that you can apply. 
 

此外,以下是有关主题的一些主题如何提高WPF UI渲染速度".希望对您有帮助.

In addition, below is some threads about topic  "how to improve WPF UI rendering speed". Hope it can be helpful to you.

提高WPF UI渲染速度的方法
http://stackoverflow.com/questions/5401549/ways-to-improve- wpf-ui-rendering-speed

Ways to improve WPF UI rendering speed
http://stackoverflow.com/questions/5401549/ways-to-improve-wpf-ui-rendering-speed

WPF性能问题的解决方案
https://www.codeproject.com/Articles/784529/Solutions-for-WPF-性能问题

Solutions for WPF Performance Issue
https://www.codeproject.com/Articles/784529/Solutions-for-WPF-Performance-Issue


最好的问候,


Best Regards,

Yohann Lu

Yohann Lu


这篇关于使UI渲染更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆