Author: NASAArticleSource: my appointment with the future (http://nasa.cnblogs.com /)
Performance Optimization
Performance monitoring (FPS )【FPS(Frames per second): number of frames transmitted per second .]
The presentation Performance of Silverlight varies depending on the complexity of the specified host parameters and content. To monitor the FPS value, we set the enableframeratecounter attributeTrue. In this way, the browser status bar displays the number of frames per second (FPS) of the displayed Silverlight content, so that you can fine-tune the applicationProgram. There are two ways to set enableframeratecounter:
1. Set enableframeratecounter = true in the attributes of the object tag.
<Div id = " Downpanel " >
<Asp: Silverlight id = " Xaml1 " Runat = " Server " Enableframeratecounter = " True " Source = " Clientbin/logsilverlight. xap " Minimumversion =" 2.0.31005.0 " Width = " 100% " Height = " 100% " Enablegpuacceleration = " True " >
<Pluginnotinstalledtemplate>
_ </Pluginnotinstalledtemplate>
</ASP: Silverlight>
</Div>
2. In CSCodeSet in (I personally think it is not easy to control)
System. Windows. InterOP. silverlighthost host = application. Current. Host;
System. Windows. InterOP. settings = host. settings;
Settings. enableframeratecounter =True;
Settings. maxframerate =60;
Notes for performance optimization:
1. Use transparent background with caution
The use of the transparent background of the Silverlight plug-in has a great impact on the performance. Therefore, avoid using this function whenever possible. Example:
param name =" background " value =" Transparent " /> param name =" windowless " value =" true " />
2. Try to use various acceleration and caching Methods
Set its cachemode attribute to true for an animation. Set the textrenderingmode attribute to renderforanimation. set its cachemode attribute to true for an opacity object and a rotation or stretch object.
3. Try to use visibility instead of opacity
If you want to set an element to be invisible, try to use visibility, because the opacity of Silverlight rendering technology will continue to consume system resources. By setting the enableredrawregions attribute, you can see their differences more intuitively, for example:
< Param Name = "Enableredrawregions" Value = "True" />
4. Do not pair mediaelementPathElement setting width and height
Setting these attributes will lead to additional stretching, which will affect performance.
5. Use stretch = "fill" when presenting a large number of images"
All types of stretching except fill and none require calculation layout (for example, calculation center ).
6. Use backgroundworker whenever possible during massive data processingWhen a large amount of data is processed, the plug-in stops rendering. S