您的位置:首页 > 其它

WPF 文本拼写检查 分类: .NET 2012-05-23 15:30 666人阅读 评论(0) 收藏

2012-05-23 15:30 323 查看
开发环境:xp sp3、vs2010、.net4.0(.net3.5没有SpellCheck.CustomDictionaries)



代码:

<Window x:Class="aaa.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=System"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox x:Name="txtBox" SpellCheck.IsEnabled="True" Language="en-us"   Margin="24,17,0,0" Height="19" VerticalAlignment="Top" HorizontalAlignment="Left" Width="211">
<SpellCheck.CustomDictionaries>
<sys:Uri>pack://application:,,,/lexicon/word.lex</sys:Uri>
</SpellCheck.CustomDictionaries>
</TextBox>
</Grid>
</Window>






因为文本框中的单词WPF并不是错误,只是系统不能识别这个单词,所以通过自定义字典来解决这个问题,

首先打开Notepad 编写词典文件(.lex),在文件中按以下格式编写单词内容(关于语言对应的ID请参考http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx):

#LID 1033
WPF
Word2
Word3
[/code]

将字典文件放到项目的lexicon目录下:



备注:单纯的文字拼写检查本人验证过,但自定义字典没有成功,在xaml中编辑代码时发现sys下没有Uri,不知道怎么回事,有知道的请告知下,在此感谢!

文章参考:http://www.cnblogs.com/gnielee/archive/2010/05/04/1727133.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐