I have a datagrid with spell checking enabled on one of the columns. The spell checker uses the default dictionary, however I would like to add a custom dictionary so that the spell checker has access to the domain specific terms added by the user.
The column is defined as follows:
<DataGrid.Columns>
<DataGridTextColumn x:Name="dgcComments" Header="Comment" Width="*" Binding="{Binding Path=Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChange}">
<DataGridColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Padding" Value="2,0,2,2" />
<Setter Property="TextAlignment" Value="Left" />
</Style>
</DataGridColumn.ElementStyle>
<DataGridColumn.EditingElementStyle>
<Style TargetType="TextBox">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="AcceptsReturn" Value="True" />
<Setter Property="Padding" Value="2,0,2,2" />
<Setter Property="TextAlignment" Value="Left" />
<Setter Property="MaxLength" Value="4000" />
<Setter Property="SpellCheck.IsEnabled" Value="True" />
</Style>
</DataGridColumn.EditingElementStyle>
</DataGridTextColumn>
...
</DataGrid.Columns>
I know I can't add the dictionary in the xaml - SpellCheck.CustomDictionaries doesn't have a setter, only add and remove methods. Is there a way to add the dictionary in the code behind? I'm stumped; I can't work out how to get access to the TextBox editing element in order to call TextBox.SpellCheck.CustomDictionary.Add().