You can have a grammar defined in file, and then update the possible products though code. For example, you can hafe following file:
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.0">
<CommandSet xml:lang="en-US" Name="ProductCommandSet">
<CommandPrefix>MyApp</CommandPrefix>
<Example> Product some product </Example>
<Command Name="Product">
<Example> Product some product </Example>
<ListenFor> Product {products} </ListenFor>
<Feedback> Selected {products} </Feedback>
<Navigate Target="/../View/ItemPage.xaml" />
</Command>
<PhraseList Label="products">
</PhraseList>
</CommandSet>
</VoiceCommands>
As you can see, ther is no list of possible products. Once you have loaded the list of product from the DB, you can update the list of commands though code. For example if you have the list of products on a variable of type List<string>
named productList
:
VoiceCommandSet commandSet = VoiceCommandService.InstalledCommandSets["ProductCommandSet"];
commandSet.UpdatePhraseListAsync("products", productList);