Terrible WPF performance!

Why do I use more than 80% of the processor when some links just hang? As you can see in the video that I downloaded: http://www.youtube.com/watch?v=3ALF9NquTRE The CPU goes to> 80% of the CPU when I move the mouse over the links.

My style for the elements is as follows

<Style x:Key="LinkStyle" TargetType="{x:Type Hyperlink}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="White" /> </Trigger> </Style.Triggers> <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" /> <Setter Property="Foreground" Value="#FFDDDDDD"/> <Setter Property="Cursor" Value="Arrow" /> </Style> 

Why?

+4
source share
3 answers

No need to be surprised - use XPerf and find out . The video on the topic given on PDC09 is excellent, you will start working quickly and quickly.

+1
source

I had a similar problem with styles in my application. If you do not see the whole xaml file of the user interface, I would ask if you are using any Bitmap effects, as this will cause problems with increased processor performance. If so, I recommend not using them and instead use optimized effect parameters or use the shader library support in WPF to apply any effects you are looking for.

In my example, I had an element with the effect of a raster shadow, which was able to switch it to a shadow effect that received the desired effect, and the processor was not affected. When I had a bitmap effect, it actually redrawn the entire area of ​​the rectangle in which the effect was turned on, so when I had a blinking cursor, it would redraw every child control from the parent in which the bitmap effect was applied.

If you are not using any effects, I recommend looking at your visual tree and see if it’s difficult with the user interface elements or, finally, and perhaps the most look, check your triggers and / or events that you may , identified for the excessive state of the displayed type of hyperlink may be something like that that causes some problems.

+1
source

A hyperlink is your own type, isn't it?

I tried applying my style to TextBlock instead and couldn't get the processor to go 5%, so maybe something happens inside the hyperlink when one of these properties changes. Try isolating which property is causing the CPU.

0
source

Source: https://habr.com/ru/post/1306393/


All Articles