Win10中的拼写检查文本框 - 慢 [英] Spell check textbox in Win10 - Slow

查看:13
本文介绍了Win10中的拼写检查文本框 - 慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 WPF 中使用内置的拼写检查器.在我让用户开始升级到 Windows 10 之前,它工作得很好……我认为问题在于它被用于许多小文本框.我的应用程序显示了一个网格(Telerik 的 TreeListView),其中包含我要检查拼写的列之一的文本框.我需要能够为拼写检查器提供自定义字典;我能够做到这一点的唯一方法是订阅文本框加载事件并添加如下路径:

I'm using the built in spell checker in WPF. It was working just fine until I had users start upgrading to windows 10... I think the issue is that it's being used for a lot of small text boxes. My application presents a grid (Telerik's TreeListView) with text boxes for one of the columns which i want spell checked. I need to be able to provide a custom dictionary to the spell checker; the only way I was able to do this was to subscribe to the textbox loaded event and add the paths in as follows:

        TextBox tb = sender as TextBox;
        tb.ContextMenu = ctx_Spell;
        IList dcts = SpellCheck.GetCustomDictionaries(tb);

        dictsList.Add(dcts);
        if (KMApplication.Settings.UserDictionary != null)
        { dcts.Add(KMApplication.Settings.UserDictionary); }

        foreach (Uri dct in KMApplication.Settings.RevitDictonaries)
        { dcts.Add(dct); }

当然,这会为每个文本框调用 add,这似乎非常浪费,但它似乎工作得很好,几乎没有明显的滞后,而且只有在加载时.但是现在在 Windows 10 上,这似乎是一个荒谬的滞后.在我的 Windows 8.1 机器上,我加载了一个包含几千行的文件,它会在大约 3 或 4 秒内出现;在我的 Windows 10 盒子上,它会在大约 10-15 分钟内出现.如果我注释掉上述代码的自定义字典部分,它在任何一台机器上都会恢复到大约 3-4 秒.

Granted this calls the add for each and every text box which seems terribly wasteful, but it seemed to be working just fine with little noticeable lag and only on load up. However now on Windows 10 it seems to be a ridiculous lag. On my Windows 8.1 machine I load up a file with a few thousand rows and it appears in about 3 or 4 seconds; on my Windows 10 box, it appears in about 10-15 minutes. If I comment out the custom dictionaries portion of the above code it's back to about 3-4 seconds on either machine.

有人知道更好的方法吗?或者如果在 Win10 中有一些解决方法?

Does anyone know a better way to do this? Or if there is some way around it in Win10?

推荐答案

从.NET 4.6.1(Win8.1 & Win10)开始,WPF使用OS公开的ISpellChecker接口来实现其SpellChecker,性能特点确实可能有些不同.

Starting .NET 4.6.1 (in Win8.1 & Win10), WPF uses ISpellChecker interface exposed by the OS to implement its SpellChecker, and the performance characteristics could be somewhat different indeed.

值得注意的是,ISpellChecker 的自定义字典注册器在全球范围内起作用 - 它不再充当每个控件的注册.(请参阅下面的知识库文章链接).因此,为每个控件一遍又一遍地注册相同的字典集是一种浪费,并且可能会降低您的性能.此外,操作系统会在达到内部限制时开始忽略您的字典.

Notably, ISpellChecker's custom dictionary registrar acts globally - it no longer acts as a per-control registration. (See KB article link below). As a result, registering the same set of dictionaries over and over for each control is wasteful and can potentially degrade your performance. Besides, the OS will just start ignoring your dictionaries when it reaches an internal limit.

只需注册一次字典,或使用 http://blogs.msdn.com/b/wpf/archive/2015/10/29/wpf-in-net-4-6-1.aspx 并将文件放在 %appdata%microsoftspelling 下.

Just register the dictionaries once, or use the alternative registration mechanism outlined at http://blogs.msdn.com/b/wpf/archive/2015/10/29/wpf-in-net-4-6-1.aspx and place the files under %appdata%microsoftspelling.

如果您需要在 Win7/Win8 以及 Win8.1/Win10 上运行相同的应用程序,您可能需要检测操作系统并分支您的字典注册策略.

If you need to run the same application on Win7/Win8 as well as Win8.1/Win10, you may need to detect the OS and branch your dictionary registration strategy.

一般来说,自定义字典的典型用法应该继续照常工作 - .NET 4.6.1 与以前的版本之间几乎没有区别.

In general, typical uses of custom dictionaries should continue working as usual - with little difference between .NET 4.6.1 vs previous releases.

另请参阅 https://support.microsoft.com/en-us/kb/3088234 了解更多信息.

Also see https://support.microsoft.com/en-us/kb/3088234 for additional information.

这篇关于Win10中的拼写检查文本框 - 慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆