Text update slowing down app

不羁的心 提交于 2019-12-07 07:34:28
Michael Sandler

TextBlocks were not noticeably faster than Labels, but Glyphs gave my calendar whiplash.

Replacing this

<TextBlock Padding="5"
           FontFamily="Narkisim"
           FontWeight="Bold"
           FontSize="20"
           Text="{Binding HebrewDate}"/>

with this

<Glyphs Name="HebrewDate"
        Margin="5"
        StyleSimulations="BoldSimulation"
        FontUri = "/Fonts/nrkis.ttf"
        FontRenderingEmSize = "20"
        UnicodeString = "5771 ןושח ה"
        Fill = "Black"/>

made scrolling super fast.

Some notes:

  1. Glyphs do not support binding, so I had to give each one a name and update them in the code behind, like so:

    HebrewDate.UnicodeString = zman.HebrewDate;
    
  2. Glyphs don't have Layout functionality so Hebrew text was coming out backwards. I had to preprocess the Hebrew strings with a reversing function. Even after reversing, the Hebrew vowel points came out misaligned, so I retained Labels for those strings which use vowels.

I can't be sure but it is possible that MS Outlook was coded in something faster than WPF, perhaps using DirectX to show the graphics rapidly.

Otherwise I might suggest toning down on the number of bindings updating at once, I would suggest using an additional thread to gradually update the labels as and when there are spare cycles instead of all at once, which might be causing your stuttering.

To go along with the previous answer, I recommend the background worker. Utilize the background worker for your most time consuming operation that gets executed during the scroll.

http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!