zoukankan      html  css  js  c++  java
  • WP7性能提示

    摘自MSDN官方文档MSDN

    ListBox

    Usage of the ItemsControl and ListBox are perhaps the most common places applications can experience performance problems. To use these controls correctly, you need to consider how many items you are going to display in your ListBox control. You next need to consider how complex the layout is for each item in the ListBox control. List boxes with complex data templates containing images and other controls may render slowly. This may result in screen jerkiness and freezing when you scroll. Data templates with complex nested stack panels and nested grids could produce performance problems. Try to simplify it down to a single Grid with the correct columns and rows.

    There are many variations of using the ListBox control, so the design approach you take depends on your exact situation. Use these controls properly, or you may not achieve the end-user experience you want.

    Panorama

    The Panorama control renders all of its UI at once, including all Silverlight bindings for all Panels. Animations on Panorama Panels that are not being viewed will still be animating and may be a performance drain. Panoramas are still a good choice for certain interactions and can still achieve good performance if used correctly.

    To achieve better performance with a Panorama, you can defer the loading of panels that are not adjacent to the one you are on. As the user pans, you then load the next adjacent one. Try to keep your controls and layout simple and you will achieve better performance.

    The Panorama control can also take up a lot more memory if you have a background image spread across the Panorama panels. To get better performance, be sure to set the background bitmap as a Resource of the assembly.

    Pivot

    Performance with a Pivot control is generally better than with the Panorama control. There are techniques you can use to make that even better. The Pivot control, when started, creates the pivot page it starts on and the adjacent pivot pages. To make a Pivot control perform better, you can set the Visibility of everything inside all adjacent pivot pages to Collapsed. This prevents it from binding and rendering any data. Then when the pivot page is in view, you can set everything to visible and the UI then renders it. You should set up a progress bar until the data is fully loaded.

    Others

    There are many more things that affect performance. Here is one last list of things to consider. They are not categorized in any way.

    • If you want to display a progress bar, use a custom indeterminate progress bar. For more information see How to: Create a Custom Indeterminate Progress Bar.

    • Use manipulation events to handle gestures as much as possible. Avoid using mouse events.

    • Minimize or eliminate garbage collection. This has a more visible effect in an XNA® Game Studio game.

    • If you have an animation that you want to take place before data is loaded in your application, you can delay the setting of the data context binding or items source until the animation is over.

    • On navigating back to a page, you don’t have to retrieve data again and rebind it unless something happened that would cause you to need to refresh it.

    • TextBlocks with opacity = 0 in a ListBox cause performance problems.

    • Avoid using a user or custom control inside the data template of a ListBox.

    • Avoid Element name binding in a ListBox control.

    • Per-frame callback animations are at the mercy of the UI thread, and as more happens on the UI thread the frame rate will go down and the animations will suffer. You can at least avoid the redraws by setting the CacheMode property to BitmapCache.

    • Any media files included in the application, such as sound effects, should have their Build Action set to Content and not Resource. Media processing on Windows Phone is optimized to use files and network streams, but not in-memory streams.

    • Separate out resource-intensive controls onto separate pages in the application so they are not all used at once. For example, don’t place a Bing map and a video on the same page.

  • 相关阅读:
    如何根据w3wp.exe的进程pid查看是哪个应用程序池
    Wpf从资源中重用UI元素
    Project not selected to build for this solution configuration.
    wpf 只在window是ShowDialog打开时才设置DialogResult
    Stop a hung service 关闭一个无响应的windows 服务
    调用windows api 获取系统分辨率
    PHP7中session_start 使用注意事项,会导致浏览器刷时页面数据不更新
    form表单清空、重置
    php用户注册常用检测、写入
    搜索条件两个时间,通过php数组排序,保证select语句between时间 前小后大
  • 原文地址:https://www.cnblogs.com/tianhonghui/p/2342279.html
Copyright © 2011-2022 走看看