This documentation is archived and is not being maintained.

InkAnalyzer Class

Provides access to layout analysis, writing and drawing classification, and handwriting recognition.

Namespace:  System.Windows.Ink
Assembly:  IAWinFX (in IAWinFX.dll)

public class InkAnalyzer : IDisposable

To add or remove strokes to the InkAnalyzer for analysis, use the AddStroke, AddStrokes, RemoveStroke, or RemoveStrokes methods. These methods update the DirtyRegion property, which defines the region that contains the strokes that are analyzed in the next analysis operation.

To analyze ink, use the Analyze or BackgroundAnalyze method. During analysis, the InkAnalyzer performs layout analysis, stroke classification, and handwriting recognition.

During analysis, the InkAnalyzer raises a number of events. Set the SynchronizingObject property to specify the thread where the InkAnalyzer will raise the events that are generated during background analysis. Many InkAnalyzer events support the data proxy features of the InkAnalyzer. For more information, see Data Proxy with Ink Analysis.

To stop the analysis process from within an event handler, call the Abort method.

To modify the language that the ink analyzer uses to recognize handwriting, use SetStrokeLanguageId or SetStrokesLanguageId. To modify how the ink analyzer classifies specific strokes, use SetStrokeType or SetStrokesType.

The InkAnalyzer loads all of the installed ink recognizers. The InkRecognizersByPriority property gets an InkRecognizerCollection containing each InkRecognizer available. If more than one ink recognizer supports a specific language, use SetHighestPriorityInkRecognizer(InkRecognizer) to designate the ink recognizer that is responsible for handling strokes for a given language.

For information about providing context for the ink analysis operation, see CreateAnalysisHint, DeleteAnalysisHint, and GetAnalysisHints.

The ink analyzer represents analysis results as a string or as a tree of ContextNode objects. To access the recognized string, use GetRecognizedString. To access the root of the tree, use the RootNode property. The ink analyzer has the following methods for finding specific context nodes or text.

To work with alternate analysis results, use GetAlternates and ModifyTopAlternate.

To save analysis results, use SaveResults. To load saved results, use Load.

For more information about using the InkAnalyzer to analyze ink, see Ink Analysis Overview.

You must explicitly call the Dispose method on any InkAnalyzer object to which an event handler is attached, before the object goes out of scope

The following example creates a new InkAnalyzer and attaches the StrokesChanged event handler to the Strokes property on the InkCanvas named theInkCanvas.

theInkAnalyzer = new InkAnalyzer();

theInkCanvas.Strokes.StrokesChanged += 
    new StrokeCollectionChangedEventHandler(Strokes_StrokesChanged);

The following example defines the Strokes_StrokesChanged event handler, which adds strokes to theInkAnalyzer if they were already added to theInkCanvas. It also removes strokes from theInkAnalyzer if they were already removed from theInkCanvas.

// This event occurs whenever a stroke is added, removed, or partially erased 
// from the InkCanvas. 
void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
    if (e.Added.Count > 0)

    if (e.Removed.Count > 0)


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.0