Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

LoadGrammarCompletedEventArgs.Grammar Property

Gets the Grammar object that has completed loading.

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

public Grammar Grammar { get; }

Property Value

Type: Microsoft.Speech.Recognition.Grammar
The Grammar object that has completed loading.

The Grammar property returns the Grammar that an application specifies in a call to LoadGrammarAsync or LoadGrammarAsync(Grammar).

In the example below, a handler for SpeechRecognitionEngine.LoadGrammarCompleted uses the Grammar property to update a display of loaded Grammar objects.

//On load we update the display.
//A hash table is used to get the node information we added in AddToTree.
_recognizer.LoadGrammarCompleted +=
    delegate(object sender, LoadGrammarCompletedEventArgs eventArgs) {
        Grammar grammar = eventArgs.Grammar;
        SrgsDocument document;
        document = _grammarDocumentList[grammar] as SrgsDocument;
        if (grammar != null) {

//Should probably do a sanity check and remove node if it exists.
TreeNode grammarNode = new TreeNode(grammar.Name);
grammarNode.Checked = grammar.Enabled;
grammarNode.Tag = grammar;

if (document != null) {
    foreach (SrgsRule rule in document.Rules) {
        TreeNode ruleNode = new TreeNode(rule.Id);

        if (document.Root == rule) {
ruleNode.ForeColor = Color.Red;

        ruleNode.Tag = rule;
        ruleNode.Checked = true;
© 2015 Microsoft