Grammar.Enabled Property

Gets or sets a value that controls whether a Grammar can be used by a recognition engine to perform recognition.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

public bool Enabled { get; set; }

Property Value

Type: System.Boolean
The Enabled property returns true if a speech recognizer can perform recognition using the speech recognition grammar; otherwise the property returns false. The default is true.

An instance of Grammar may be enabled or disabled independently of being loaded by a SpeechRecognitionEngine object.

The following example shows a check box handler for a TreeView. When the box is checked, the grammar is enabled.

private void _grammarTreeView_AfterCheck(object sender, TreeViewEventArgs eventArgs) 
  if (eventArgs.Action != TreeViewAction.Unknown) 
  { // Avoid recursion due to handlers
    if (eventArgs.Node.Parent == null) 
      Grammar grammar = ((Grammar)eventArgs.Node.Tag);
      grammar.Enabled = eventArgs.Node.Checked;