Loading...
Loading...
Guide for implementing Syncfusion WPF SpellChecker (SfSpellChecker) control in WPF applications. Use this skill when implementing spell checking, text validation, dictionary management, or spelling error detection in WPF. Covers checking spelling mistakes in TextBox/RichTextBox controls, language dictionaries, custom dictionaries, context menu suggestions, and spelling validation requirements.
npx skill4agent add syncfusion/wpf-ui-components-skills syncfusion-wpf-spellcheckerSyncfusion.Windows.ControlsSyncfusion.SfSpellChecker.WPF<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
<Grid>
<StackPanel>
<TextBox
Text="Ths is a sampel text with speling errors."
Name="textbox"
TextWrapping="Wrap">
<!--Attach SpellChecker to TextBox-->
<syncfusion:SfSpellChecker.SpellChecker>
<syncfusion:SfSpellChecker
x:Name="spellChecker"
EnableSpellCheck="True"/>
</syncfusion:SfSpellChecker.SpellChecker>
</TextBox>
<Button
Content="Spell Check"
Click="SpellCheck_ButtonClick"
HorizontalAlignment="Center"/>
</StackPanel>
</Grid>
</Window>// Code-behind
private void SpellCheck_ButtonClick(object sender, RoutedEventArgs e)
{
spellChecker.PerformSpellCheckUsingDialog();
}<syncfusion:SfSpellChecker
x:Name="spellChecker"
EnableSpellCheck="True"
EnableContextMenu="True"/>// Create spell checker instance
SfSpellChecker spellChecker = new SfSpellChecker();
spellChecker.EnableSpellCheck = true;
// Attach to TextBox
SfSpellChecker.SetSpellChecker(textbox, spellChecker);
// Open spell check dialog
spellChecker.PerformSpellCheckUsingDialog();SfSpellChecker spellChecker = new SfSpellChecker();
spellChecker.EnableSpellCheck = true;
spellChecker.EnableContextMenu = true;
// Configure ignore options
spellChecker.IgnoreUrl = true;
spellChecker.IgnoreEmailAddress = true;
spellChecker.IgnoreUpperCaseWords = true;
SfSpellChecker.SetSpellChecker(textbox, spellChecker);// Create culture-specific spell checker
CultureInfo culture = new CultureInfo("fr-FR");
SfSpellChecker spellChecker = new SfSpellChecker();
// Add French dictionary
spellChecker.Dictionaries = new DictionaryCollection();
spellChecker.Dictionaries.Add(
new HunspellDictionary()
{
Culture = culture,
GrammarUri = new Uri("/MyApp;component/Dictionaries/fr-FR.aff", UriKind.Relative),
DictionaryUri = new Uri("/MyApp;component/Dictionaries/fr-FR.dic", UriKind.Relative)
}
);
spellChecker.Culture = culture;
SfSpellChecker.SetSpellChecker(textbox, spellChecker);// Add custom words dictionary
Uri customDictUri = new Uri(Directory.GetCurrentDirectory() +
@"\Dictionaries\CustomWords.txt", UriKind.Absolute);
spellChecker.Dictionaries.Add(
new CustomDictionary()
{
Culture = new CultureInfo("en-US"),
DictionaryUri = customDictUri
}
);spellChecker.SpellCheckCompleted += (sender, e) =>
{
// Suppress default message box
(e as SpellCheckCompletedEventArgs).ShowMessageBox = false;
// Custom completion logic
MessageBox.Show("Spell check completed!", "Done");
};| Property | Type | Description |
|---|---|---|
| bool | Enable/disable spell checking (default: true) |
| bool | Enable context menu suggestions (default: true) |
| CultureInfo | Culture for spell checking |
| DictionaryCollection | Collection of dictionaries |
| bool | Ignore internet addresses |
| bool | Ignore email addresses |
| bool | Ignore HTML tags |
| bool | Ignore mixed case words (e.g., AbCDeFH) |
| bool | Ignore all uppercase words |
| bool | Ignore words with numbers |
| Method | Description |
|---|---|
| Opens spell check dialog |
| Gets suggestion list for error word |
| Gets phonetic word suggestions |
| Gets anagram suggestions |