Cortana VCD: set command Move target page to subfolder
I'm having trouble launching a specific page of my Windows Phone 8.1 app via Cortana. I registered the VCD and the command is successfully recognized by Cortana. But when the command is executed, the application will launch its default page (MainPage.xaml). I want to run ReportPage.xaml instead of MainPage.xaml.
All pages are located under a subfolder called "View" (as opposed to the default project template when you create the application).
I tried several combinations, but none worked:
<Navigate Target="ReportPage.xaml" />
<Navigate Target="View/ReportPage.xaml" />
<Navigate Target="/View/ReportPage.xaml" />
<Navigate Target="ReportPage" />
Here's my VCD:
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-US">
<CommandPrefix>Traffic Reporter</CommandPrefix>
<Example>Report a traffic incident</Example>
<Command Name="ReportIncident">
<Example>Start reporting a traffic incident</Example>
<ListenFor>Report</ListenFor>
<ListenFor>Report an {SortOfIncident}</ListenFor>
<ListenFor>Report a {SortOfIncident}</ListenFor>
<Feedback>Starting the report</Feedback>
<Navigate Target="ReportPage.xaml" />
</Command>
<PhraseList Label="SortOfIncident">
<Item>accident</Item>
<Item>incident</Item>
<Item>speed trap</Item>
<Item>speed check</Item>
</PhraseList>
</CommandSet>
</VoiceCommands>
+3
source to share
1 answer
Assuming you are in a Windows Store App (WinRT): Do you handle voice activation in your App.OnActivated Method?
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.VoiceCommand)
{
Frame rootFrame = Window.Current.Content as Frame;
VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args;
//check for the command name that launched the app
string voiceCommandName = vcArgs.Result.RulePath.FirstOrDefault();
switch (voiceCommandName)
{
case "ViewEntry":
rootFrame.Navigate(typeof(ViewDiaryEntry), vcArgs.Result.Text);
break;
case "AddEntry":
case "EagerEntry":
rootFrame.Navigate(typeof(AddDiaryEntry), vcArgs.Result.Text);
break;
}
}
}
+2
source to share