Message 1 of 3
"Ignore All" Button Not Stopping Spell Check Process in WPF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I am implementing a spell check feature in my Revit add-in using WPF. The issue I am facing is that when I click "Ignore All", the spell check window still opens for each word instead of stopping immediately.
External Command
public bool stopProcessing = false; // Flag to stop processing
public void OpenSpellCheckWindowForWord(List<string> incorrectWords)
{
// Create a new SpellCheckWindow for the current word
SpellCheckWindow spellCheckWindow = new SpellCheckWindow(incorrectWords, ref stopProcessing);
// Make a copy of the list to loop over
List<string> wordsToProcess = new List<string>(incorrectWords);
// Loop through the list of incorrect words and open a window for each
foreach (string word in wordsToProcess)
{
// If stopProcessing flag is true, stop processing
if (stopProcessing)
{
break;
}
// Set the word to display in the UI elements (TextBoxes)
spellCheckWindow.IncorrectWordsTextBox.Text = word;
spellCheckWindow.NotInDictionaryTextBox.Text = word;
// Show the window and block further execution until it is closed
bool dialogResult = (bool)spellCheckWindow.ShowDialog();
// If "Ignore All" was clicked, stop processing
if (stopProcessing)
{
break;
}
}
}
WPF Spell Check Window Code (Behind Code)
// For Ignore Button click
private void IgnoreButton_Click(object sender, RoutedEventArgs e)
{
if (IncorrectWords.Any())
{
// Remove the current word from the list
IncorrectWords.RemoveAt(0);
// Close the current window to show the next word
this.Close();
}
}
// For Ignore All Button click
private void IgnoreAllButton_Click(object sender, RoutedEventArgs e)
{
// Clear all incorrect words
IncorrectWords.Clear();
// Set the stopProcessing flag to true to signal external command to stop processing
_stopProcessing = true;
// Close the current spell check window
this.Close();
}
Expected Behavior:
- Clicking "Ignore" should move to the next word. ✅
- Clicking "Ignore All" should immediately stop the spell check process and close all windows. ❌ (Not working)
Issue:
Even after setting _stopProcessing = true, the spell check window still opens for each remaining word instead of stopping immediately.
Question:
How can I ensure that clicking "Ignore All" stops the process immediately and prevents additional spell check windows from opening?
Would love to hear any suggestions or best practices! Thanks.
Developer Advocacy and Support +