Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPF on .NET 8.0 > TextBox.SpellCheck custom dictionary has no effect #9760

Open
vsfeedback opened this issue Sep 11, 2024 · 6 comments
Open
Labels
Investigate Requires further investigation by the WPF team.

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version]
Hello,

I am currently facing the problem that the SpellCheck of the TextBox WPF-Control does not seem to load my lexicon file correctly.

Per documentation I am using the following code to load the dictionary:

txtContent.Language = System.Windows.Markup.XmlLanguage.GetLanguage("de-DE");
txtContent.SpellCheck.CustomDictionaries.Clear();
txtContent.SpellCheck.CustomDictionaries.Add(new Uri(@"C:\temp\test.lex", UriKind.Absolute));
txtContent.SpellCheck.IsEnabled = true;

The TextBox is defined in XAML as follows:

<TextBox x:Name="txtContent" DockPanel.Dock="Top"
         BorderThickness="0"
         Margin="0,0,0,0" Width="Auto" Height="Auto"
         SpellCheck.IsEnabled="false"
         IsInactiveSelectionHighlightEnabled="true"
         AcceptsReturn="True" AcceptsTab="True"
         Visibility="Visible"
         VerticalScrollBarVisibility="Auto" TextChanged="txtContent_TextChanged"
         SelectionChanged="TextBox_SelectionChanged" IsReadOnlyCaretVisible="True"
         ScrollViewer.ScrollChanged="txtContent_ScrollViewer_ScrollChanged"
         PreviewMouseWheel="txtContent_PreviewMouseWheel">
</TextBox>

The file "test.lex" contains the following lines:

#LID 1031
Datenbox
Dokumentenboard
Infoboard

Still, when I type the word "Datenbox" in the TextBox control, it underlines the word and tries to correct it.

When I retrieve the custom dictionaries using "SpellCheck.GetCustomDictionaries", I can see that the dictionary was in fact loaded. It just isn't applied for some reason.

Project Information:

<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<PlatformTarget>x64</PlatformTarget>

Any help or hints would be greatly appreciated!

Kind regards,
Lukas


Original Comments

Feedback Bot on 9/11/2024, 07:10 AM:

(private comment, text removed)


Original Solutions

(no solutions)

@himgoyalmicro himgoyalmicro added the Investigate Requires further investigation by the WPF team. label Sep 11, 2024
@miloush
Copy link
Contributor

miloush commented Sep 11, 2024

Do you have a repro project?

@LukinTV
Copy link

LukinTV commented Sep 11, 2024

@miloush I created a public repo with a minmal reproducible sample, you can find it here: https://github.com/LukinTV/WPF-SpellCheck-CustomDictionary.

Just be sure to change the absolute path to the .lex-file to wherever you cloned to project: txtSpellCheck.SpellCheck.CustomDictionaries.Add(new Uri(@"C:\temp\Repro\WPF-SpellCheck-CustomDictionary\custom.lex", UriKind.Absolute));

@lindexi
Copy link
Contributor

lindexi commented Sep 12, 2024

Reference #9701

@LukinTV
Copy link

LukinTV commented Sep 12, 2024

Reference #9701

Also, https://stackoverflow.com/questions/77258504/wpf-spellcheck-on-windows-11-systems/.
This seems to be a common problem.

@lindexi
Copy link
Contributor

lindexi commented Sep 12, 2024

I've tried to investigate the problem, but I've had no luck

@alraseensaad
Copy link

Even with default spell check it sometimes works and sometimes not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

6 participants