WPF Form Loads very slow after adding SpellCheck.IsEnabled to a Control

五迷三道 提交于 2019-12-08 03:30:17

问题


So I have a mysterious issue where after I've added SpellCheck.IsEnabled to one of my controls the form that hosts this control takes upwards of 3 seconds to load. Remove the spell check attribute and the form loads instantly.

Just for reference, the following is the only place changed in the form:

<TextBox TextWrapping="Wrap" Height="100"
         Text="{Binding ActivePostMetadata.Abstract}" SpellCheck.IsEnabled="True" 
         IsEnabled="{Binding IsAbstractVisible}" 
                          />

With SpellCheck.IsEnabled="True" the form's InitializeLayout takes ~3 seconds, without it the initialization is instant.

To make things even more odd: It happens only on my dev machine. When running the compiled application on another machine there's no problem with the form popping up instantly.

I suspect it has to do with a possible Windows issue of finding dictionaries, but I have no idea where to look.

Any ideas what could be going on here?


回答1:


Ok, after a bit more research it looks like the problem is due to many temporary dictionary files registered here:

HKCU\SOFTWARE\Microsoft\Spelling\Dictionaries

I had about 20 dictionaries registered in tmpFiles many of which don't exist. tmpFiles has a lot of files in it and likely the file lookup along with the 2 or 3 dictionaries there that are actually available caused the slow down. Not sure what's dumping temporary dictionaries there, but I removed all the temporary files from the listing (leaving in my case just the Word dictionary) and now the form loads quickly again.

More info on where dictionary info comes from and what ultimately let me find this comes from here:

https://msdn.microsoft.com/en-us/library/windows/desktop/hh869748(v=vs.85).aspx



来源:https://stackoverflow.com/questions/46394790/wpf-form-loads-very-slow-after-adding-spellcheck-isenabled-to-a-control

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