Silverlight C# - ComponentOne 拼写检查器未加载字典
这可能是一个远景,但我正在使用 ComponentOne 的 Silverlight 拼写检查器控件。我创建了一个测试项目,向其中添加了一个纯文本框和一个按钮,添加了对 C1.Silverlight 和 C1.Silverlight.SpellChecker 位的引用,并将字典文件添加到了我的项目中。
在代码中,我在 Button1 的单击事件上调用了拼写检查器,它运行得非常好。拼写检查对话框出现,并且完全正常工作。
由于测试成功,我尝试将其实施到我现有的项目中。我没有成功,因为我无法确定任何原因,因为我使用了完全相同的代码。
以下是我用来调用组件的代码:
using C1.Silverlight;
using C1.Silverlight.SpellChecker;
using C1.Silverlight.Resources;
public partial class MainPage : UserControl
{
C1SpellChecker spellChecker = new C1SpellChecker();
public MainPage()
{
InitializeComponent();
spellChecker.MainDictionary.LoadAsync("C1Spell_en-US.dct");
}
private void btnSpelling_Click(object sender, RoutedEventArgs e)
{
var dlg = new C1SpellDialog();
spellChecker.CheckControlAsync(txtArticle, false, dlg);
}
对 C1.Silverlight
和 C1.Silverlight.Spellchecker
的引用也添加到此项目中,并且添加了字典也以同样的方式。问题似乎是,无论出于何种原因,字典都没有加载,因为pellChecker.Enabled 方法返回主字典是否已加载。如果我调用 MessageBox.Show("SpellChecker Enabled = " +pellChecker.Enabled.ToString());
它会显示 false,即使存在加载字典的调用(如您所见)。
什么原因会导致词典无法加载?我是否以某种方式错误地将其添加到我的项目中?
编辑:我怀疑我已将字典错误地添加到项目中,因为 ComponentOne 参考 指出:
如果 C1SpellChecker 找不到 拼写字典,它不会抛出 任何例外情况。已启用属性 将被设置为 false 并且组件 将无法对任何内容进行拼写检查 文本。
我只是不知道出了什么问题,因为它的添加方式与测试项目中的添加方式相同(右键单击project.web->添加->现有项目)
一如既往,谢谢!
-苏塔
This may be a long shot, but I'm using ComponentOne's Spellchecker control for Silverlight. I made a test project, added a plain textbox and a button to it, added the references to the C1.Silverlight and C1.Silverlight.SpellChecker bits, and added the dictionary file to my project.
In the code, I called up the spellchecker on button1's click event and it worked SPLENDIDLY. The spellchecker dialog shows up, and works exactly as it should.
Since that test was successful, I then tried to implement this into my existing project. I've had no success for absolutely NO reason that I can determine, since I used the EXACT SAME code.
Here's the code I use to call the component:
using C1.Silverlight;
using C1.Silverlight.SpellChecker;
using C1.Silverlight.Resources;
public partial class MainPage : UserControl
{
C1SpellChecker spellChecker = new C1SpellChecker();
public MainPage()
{
InitializeComponent();
spellChecker.MainDictionary.LoadAsync("C1Spell_en-US.dct");
}
private void btnSpelling_Click(object sender, RoutedEventArgs e)
{
var dlg = new C1SpellDialog();
spellChecker.CheckControlAsync(txtArticle, false, dlg);
}
The references to C1.Silverlight
and C1.Silverlight.Spellchecker
are added to this project as well, and the dictionary as been added in the same fashion as well. The issue seems to be that for whatever reason the dictionary is not loading, because the spellChecker.Enabled method returns whether or not the main dictionary has been loaded. If I call MessageBox.Show("SpellChecker Enabled = " + spellChecker.Enabled.ToString());
it shows false, even though the call to load the dictionary is there (as you can see).
What would cause the dictionary to not load? Have I added it to my project incorrectly somehow?
EDIT: I suspect that I have added the dictionary to the project incorrectly, because the ComponentOne reference states:
If C1SpellChecker cannot find the
spelling dictionary, it will not throw
any exceptions. The Enabled property
will be set to false and the component
will not be able to spell-check any
text.
I just don't know what's wrong though because it was added in the same way that it was in the test project (Right clicked on the project.web->Add->Existing Item)
As always, thank you!
-Sootah
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将字典作为嵌入资源添加到 Silverlight 应用程序,然后使用以下代码加载它:
You could add the dictionary to the Silverlight app as an embedded resource and then load it using this code:
我认为这篇文章在我们的论坛中也有重复,但首先会在这里回答。请尝试以下操作:
1) 尝试使用浏览器访问 .dct 文件。如果您看不到它,可能是因为您的网络服务器不提供该类型的文件。您需要配置 Web 服务器以允许它。
2) 验证您使用的 URL 是否正确。http://helpcentral.componentone.com/CS/silverlight_161/f/78/p/86955/241328.aspx#241328
3) 检查您是否正确设置了所有内容:http://helpcentral.componentone.com/CS/silverlight_161/ f/78/p/81924/227790.aspx#227790
希望这有帮助!
I think this post is duplicated in our forum as well, but will answer first here. Please try this:
1) Try to access the .dct file using your browser. If you cannot see it, it's probably because your web server is not serving that type of files. You need ton configure the web server to allow it.
2) verify the URL you are using is correct.http://helpcentral.componentone.com/CS/silverlight_161/f/78/p/86955/241328.aspx#241328
3) Check you are setting everything correctly: http://helpcentral.componentone.com/CS/silverlight_161/f/78/p/81924/227790.aspx#227790
Hope this helps!