将 SpellCheck.IsEnabled 添加到控件后,WPF 表单加载速度非常慢 [英] WPF Form Loads very slow after adding SpellCheck.IsEnabled to a Control
问题描述
所以我有一个神秘的问题,在我将 SpellCheck.IsEnabled
添加到我的一个控件后,承载此控件的表单需要 3 秒以上的时间才能加载.删除拼写检查属性,表单会立即加载.
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}"
/>
使用 SpellCheck.IsEnabled="True"
表单的 InitializeLayout 需要大约 3 秒,没有它初始化是即时的.
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.
我怀疑这可能与查找字典的 Windows 问题有关,但我不知道去哪里找.
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?
推荐答案
好的,经过一些研究,问题似乎是由于此处注册的许多临时字典文件造成的:
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
我在 tmpFiles
中注册了大约 20 个字典,其中许多都不存在.tmpFiles 中有很多文件,可能是文件查找以及实际可用的 2 或 3 个字典导致速度变慢.不确定是什么在那里转储临时字典,但我从列表中删除了所有临时文件(在我的例子中只留下 Word 字典),现在表单再次快速加载.
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
这篇关于将 SpellCheck.IsEnabled 添加到控件后,WPF 表单加载速度非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!