I'm looking at changing my spell checking implementation to use Syncfusion spell checking. I've got it mostly working but have one question and one issue. First my code for the test app. I followed the sample code here and got that working, then I wanted to apply it to multiple textboxes on the same window as that is how it will be in my actual application. Last I tried to activate a custom dictionary.
Here is my XAML code for the app window:
<Window x:Class="SyncfusionWpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Icon="App.ico">
<Grid>
<StackPanel>
<TextBox Loaded="tb_Loaded" />
<TextBox Loaded="tb_Loaded" />
<TextBox Loaded="tb_Loaded" />
</StackPanel>
</Grid>
Here is the code behind:
using System.Windows;
using System.Windows.Controls;
using Syncfusion.Windows.Controls;
namespace SyncfusionWpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
void tb_Loaded(object sender, RoutedEventArgs e)
{
var spellChecker = new SfSpellChecker
{
CustomDictionaryPath =
@"C:\Users\sfaust\Source\Repos\SFTest1\SyncfusionWpfApp1\SyncfusionWpfApp1\bin\Debug\testdictionary.txt"
};
var textBoxSpellEditor = new TextBoxSpellEditor((TextBox)sender);
spellChecker.PerformSpellCheckUsingContextMenu(textBoxSpellEditor);
}
}
}
Ok so first question. Once I moved to multiple controls it seemed like it didn't work right unless I create a new spell checker and new IEditorProperties (the TextBoxSpellEditor class) for each textbox and applied it (hence initializing it in loaded above instead of in the window like the example). Well this seems to work it seems pretty inefficient as well. My application will potentially have quite a few text boxes in it as they are inside a tree view of items so I'm a little concerned about the efficiency of having potentially hundreds of spell checkers instantiated (though I haven't tried a stress test so maybe I'm concerned unnecessarily). Is this the correct way to do this?
Second question is more of an issue. I don't see anything indicating the custom dictionary is working. I created the file at the path shown and put a few random "words" in it that it identified (correctly) as misspelled but even after putting them in that file and setting the custom dictionary path property it still identifies them as misspelled. I also don't have the 'AddToDictionary' option on the context menu. I also tried to just set the property without actually creating the file in case it wanted to create the file itself but no change. Last I tried both relative and absolute paths but no change there either. Is there something I am missing on how to activate the custom dictionary?