Open control0forver opened 3 months ago
Does it help you to check whether the RenderingTime
has increased after the previous CompositionTarget.Rendering
event?
As far as I understand CompositionTarget.Rendering
might be raised more than once per frame.
private void CompositionTarget_Rendering(object? sender, EventArgs e)
{
var args = (RenderingEventArgs)e;
if (_lastRenderingTime == args.RenderingTime)
return;
_lastRenderingTime = args.RenderingTime;
_currentFps++;
}
I noticed via the System.Windows.Media.CompositionTarget.Rendering event that the app's frames per second are very irregular, when I use the mouse to interact with a visual control, the frames per second instantly goes from around 60 to over 400, and it occurred to me that this is most likely due to my customizing the style of the control. So I wondered if I could limit the frames per second of a UIElement through code; I found this code, but it seems to only limit the framerate of the final rendering of the entire app, and it still doesn't limit the frames per second of a UIElement
Here's the frame rate monitor I mentioned above along with the custom control styling code: