Silverlight is timeline-based, unlike flash, Which is frame-based. Therefore, in Silverlight, it is rare to see a document specifically describing frames in SL.
However, we know from the animation principle that an animation only plays a static picture continuously and uses the human eye's vision for the moment. Therefore, in principle, there is a concept of at least how many frames are played per second.
In the SDK documentation of Silverlight, there is a paragraph:
...
The maxframerate value can be configured through the maxframerate parameter of the Silverlight plug-in object. The default value of maxframerate is 60. Currentframerate and maxframerate are the reported frames per second (FPS) values. The actual displayed frame rate is set to a lower number. You can elaborate the relationship between currentframerate and maxframerate by setting a lower value (for example, 2 frames per second.
...
That is, SL can play up to 60 frames per second by default. Of course, we can use code to change this value (for example, set it to 100), but the current playback speed of SL is related to hardware, it's not how high you want to be.
Test XAML:
Code by Yang Guo http://yjmyzz.cnblogs.com under the bodhi tree/
<Usercontrol X: class = "compositiontarget_rendering.mainpage"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns: D = "http://schemas.microsoft.com/expression/blend/2008" xmlns: MC = "http://schemas.openxmlformats.org/markup-compatibility/2006"
MC: ignorable = "D" D: designwidth = "640" D: designheight = "480">
<Stackpanel X: Name = "layoutroot" horizontalalignment = "center" verticalignment = "center">
<Textblock text = "ready" X: Name = "TXT" horizontalalignment = "center"> </textblock>
<Stackpanel margin = "5">
<Slider width = "200" minimum = "1" Maximum = "100" X: Name = "Slider" valuechanged = "slider_valuechanged" value = "60"> </slider>
<Textblock X: Name = "txtmax" margin = "," horizontalalignment = "center" text = "60"> </textblock>
</Stackpanel>
</Stackpanel>
</Usercontrol>
In SL, A compositiontarget. Rendering event can be triggered when each frame enters (the first playback) and the CS code is tested:
Code by Yang Guo http://yjmyzz.cnblogs.com under the bodhi tree/
Using system;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. InterOP;
Using system. Windows. Media;
Namespace compositiontarget_rendering
{
Public partial class mainpage: usercontrol
{
Bool isloaded = false;
Public mainpage ()
{
Initializecomponent ();
This. Loaded + = new routedeventhandler (mainpage_loaded );
}
Void mainpage_loaded (Object sender, routedeventargs E)
{
Compositiontarget. Rendering + = new eventhandler (compositiontarget_rendering );
Isloaded = true;
}
/// <Summary>
/// This event is triggered when each frame is entered.
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Void compositiontarget_rendering (Object sender, eventargs E)
{
This.txt. Text = datetime. Now. tostring ("yyyy-mm-dd hh: mm: SS: fff ");
}
Private void slider_valuechanged (Object sender, routedpropertychangedeventargs <double> E)
{
If (isloaded)
{
Settings settings = application. Current. Host. settings;
Settings. enableframeratecounter = true;
Settings. maxframerate = (INT) slider. value;
Txtmax. Text = settings. maxframerate. tostring ();
}
}
}
}
When entering each frame, we will show the current time in txt, drag the slider, and set the number of frames played by the current animation per second. Running effect:
Drag the slider to observe the speed of time update, and pay attention to the display of the status bar in the lower left corner of the browser. Of course, compositiontarget. rendering is not only used to display time, but also to do more things. Let's take full advantage of it :)