GestureRecognizer.IsRecognizerAvailable Property


Gets a Boolean that indicates whether the gesture recognizer is available on the user's system.

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

public bool IsRecognizerAvailable { get; }

Property Value

Type: System.Boolean

true if the recognition component is available; otherwise, false.

The following example demonstrates how to determine whether the gesture recognizer is available before calling the Recognize method.

private bool InterpretScratchoutGesture(Stroke stroke)
    // Attempt to instantiate a recognizer for scratchout gestures.
    ApplicationGesture[] gestures = {ApplicationGesture.ScratchOut};
    GestureRecognizer recognizer = new GestureRecognizer(gestures);

    if (!recognizer.IsRecognizerAvailable)
        return false;

    // Determine if the stroke was a scratchout gesture.
    StrokeCollection gestureStrokes = new StrokeCollection();

    ReadOnlyCollection<GestureRecognitionResult> results = recognizer.Recognize(gestureStrokes);

    if (results.Count == 0)
        return false;

    // Results are returned sorted in order strongest-to-weakest; 
    // we need only analyze the first (strongest) result.
    if (results[0].ApplicationGesture == ApplicationGesture.ScratchOut &&
          results[0].RecognitionConfidence == RecognitionConfidence.Strong)
        // Use the scratchout stroke to perform hit-testing and 
        // erase existing strokes, as necessary.
        return true;
        // Not a gesture: display the stroke normally.
        return false;

.NET Framework
Available since 3.0
Return to top