【发布时间】:2011-06-15 00:45:17
【问题描述】:
我正在尝试逐字遍历文本框中的文本以进行拼写检查。我已将文本框的内容拆分为一个数组,并遍历数组中的每个单词并通过拼写检查器运行它。当发现拼写错误时,我会弹出一个带有列表框的弹出窗口,以便您选择更正。
我遇到的问题是,它只是循环遍历整个数组,最后只显示需要完成的最后一次更正。
如何暂停循环以等待做出选择然后恢复?
这是循环的代码:
foreach(string checkedWord in articleWords)
{
bool success = _spellChecker.CheckWord(checkedWord);
List<string> suggest;
if (!success)
{
suggest = _spellChecker.GetSuggestions(checkedWord);
SpellChecklistBox.Items.Clear();
foreach (string s in suggest)
{
SpellChecklistBox.Items.Add(new ListBoxItem() { Content = s });
}
SpellCheckerPopup.IsOpen = true;
SpellChecklistBox.Items.Add(new ListBoxItem() { Content = " ----------------------" });
SpellChecklistBox.Items.Add(new ListBoxItem() { Content = "Ignore" });
}
}
当 SpellCheckerPopup 显示时,我在 SelectionChange 的列表框中有一个事件触发器。
基本上,我需要以某种方式暂停循环,然后当 SelectionChange 事件发生时,让循环恢复。
提前致谢!
-苏塔
【问题讨论】:
标签: c# silverlight web-applications silverlight-4.0