gpt4 book ai didi

c# - 小娜 VCD : set command's Navigate target to a Page in a subfolder

转载 作者:行者123 更新时间:2023-11-30 16:54:27 24 4
gpt4 key购买 nike

我在通过 Cortana 启动 Windows Phone 8.1 应用程序的特定页面时遇到问题。我已经注册了一张 VCD,Cortana 成功识别了该命令。但是当执行命令时,应用程序将启动其默认页面 (MainPage.xaml)。我想启动 ReportPage.xaml 而不是 MainPage.xaml。

所有页面都在名为“View”的子文件夹下(与创建应用程序时的默认项目模板不同)。

我尝试了几种组合,但都没有奏效:

<Navigate Target="ReportPage.xaml" />
<Navigate Target="View/ReportPage.xaml" />
<Navigate Target="/View/ReportPage.xaml" />
<Navigate Target="ReportPage" />

这是我的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>

最佳答案

假设您在 Windows 应用商店应用程序 (WinRT) 中:您是否在App.OnActivated 方法中处理语音激活?

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;
}
}
}

关于c# - 小娜 VCD : set command's Navigate target to a Page in a subfolder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30509194/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com