Knowledgebase Home Page  >  RapidSpell Silverlight
Search the Knowledge Base
How to spell check a TextBlock (C#)
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=256&catId=68

Options

Print this page
Email this to a friend

To spell check a TextBlock control;

 

Add this class to your project

 

  public class TextBlockAdapter : ISpellCheckableTextComponent

    {

        int selectionStart, selectionLength;

        TextBlock tb;

        public TextBlockAdapter(TextBlock block)

        {

            tb = block;

        }

 

        public void Dispose()

        {

           

        }

 

        public event EventHandler Disposed;

 

        public bool Enabled

        {

            get { return true; }

        }

 

        public event EventHandler GotFocus;

 

        public bool HideSelection

        {

            get

            {

                return false;

            }

            set

            {

               

            }

        }

 

        public bool ReadOnly

        {

            get { return false; }

        }

 

        public void ScrollToCaret()

        {

           

        }

 

        public string SelectedText

        {

            get

            {

                return tb.Text.Substring(SelectionStart, SelectionLength);

            }

            set

            {

                tb.Text=tb.Text.Substring(0, SelectionStart)+value+tb.Text.Substring(SelectionStart+SelectionLength);

            }

        }

 

        public int SelectionLength

        {

            get

            {

                return selectionLength; ;

            }

            set

            {

                selectionLength = value;

            }

        }

 

        public int SelectionStart

        {

            get

            {

                return selectionStart;

            }

            set

            {

                selectionStart = value;

            }

        }

 

        public string Text

        {

            get

            {

                return tb.Text;

            }

            set

            {

                tb.Text = value;

            }

        }

    }

 

 

Set it up to be spell checked like this

 

rapidSpellDialog1.AddTextComponent(new TextBlockAdapter(textBlock1));

 

 

 


Related Questions:

Attachments:

No attachments were found.