Click here to Skip to main content
14,030,704 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


9 bookmarked
Posted 12 Mar 2013
Licenced GPL3

AvalonEdit and Spell check

, 14 Mar 2013
Rate this:
Please Sign up or sign in to vote.
Quick hack for spell check with AvalonEdit.


As the name of the article implies, this is a quick hack to add spell check in your application using the brilliant AvalonEdit. This is a quick tricky/dirty way to implement spell check using the built-in spell checker in .NET without relying on 3rd party libraries. Note that this might not be the most efficient way of spell check. 


AvalonEdit is a popular open source text editor control used in #D and widely used by many open source developers in their open source projects. When I started using AvalonEdit, I wanted to add spell check in my application. Initially, I was under the assumption that AvalonEdit inherits from TextBoxBase which means that I can just use the inbuilt spell checker. However that is not the case - AvalonEdit inherits from Control.

The Idea 

In my implementation (See source code) - there are two pieces of development: 

  1. Every AvalonEdit text editor control has a corresponding TextBox control exclusively to get spelling errors. Every change to the text editor will also update the text box - thereby letting the application get the spelling errors. This has been implemented by creating a behavior called SpellCheckBehavior for AvalonEdit.
  2. A new DocumentColorizingTransformer called the SpellingErrorColorizer, is available as a part of the code. This needs to be added to the list of line transformers in the text view of your editor. The idea behind this transformer is using a static text box which can give the errors on the DocumentLine that needs to be processed. 

The Result

Using the code

Download the code and have a look at it as it is self explanatory. 

In MainWindow.xaml, create an instance of the text editor and add the behavior. 

<avalonedit:TextEditor Name="textEditor" FontSize="20">
        <SpellCheckAvalonEdit:SpellCheckBehavior />

In MainWindow.xaml.cs, add the SpellingErrorColorizer to the line transformers.

public MainWindow()
    textEditor.TextArea.TextView.LineTransformers.Add(new SpellingErrorColorizer());

Note: In this implementation, I did not care about the performance. If you have a better suggestions, please share/contribute. 


  • 03/11/13 - First spell check idea.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Software Developer
United States United States
Hello! I'm a 26 year old, WPF/C# self-learned software developer, musician from India with a Master's degree in Computer science. I believe that every piece of software and information/knowledge is available for free for those who seek it.

My projects are available in my Webpage hosted on Github. I am eager to learn new things everyday, explore new technologies and solve problems.

Comments and Discussions

QuestionIs MSWord on machine is needed where this application will run? Pin
HM India1-Aug-13 12:36
professionalHM India1-Aug-13 12:36 
AnswerRe: Is MSWord on machine is needed where this application will run? Pin
Chandramouleswaran1-Aug-13 15:50
memberChandramouleswaran1-Aug-13 15:50 
QuestionDownload unavailable Pin
Dirk Bahle14-Mar-13 2:09
mvaDirk Bahle14-Mar-13 2:09 
AnswerRe: Download unavailable Pin
Chandramouleswaran14-Mar-13 4:48
memberChandramouleswaran14-Mar-13 4:48 
GeneralRe: Download unavailable Pin
Dirk Bahle15-Mar-13 10:43
mvaDirk Bahle15-Mar-13 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190419.4 | Last Updated 14 Mar 2013
Article Copyright 2013 by Chandramouleswaran
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid