2017-12-04 22 views
1

동적으로 내 VCD 파일을 채울 방법을 찾고 있습니다. 내가 App.OnActivated() 비주얼 스튜디오는 VoiceCommandSet 윈도우 "에 포함되어 있지 않다는 오류를 보여줍니다 내 버전으로이 둘 때,VoiceCommand PhraseList를 동적으로 채우고 오류 VoiceCommandSet을 찾을 수 없음

Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition.VoiceCommandSet commandSetEnUs; 

if (Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager. 
     InstalledCommandSets.TryGetValue(
     "AdventureWorksCommandSet_en-us", out commandSetEnUs)) 
{ 
    await commandSetEnUs.SetPhraseListAsync(
    "destination", new string[] {“London”, “Dallas”, “New York”, “Phoenix”}); 
} 

을하지만 : 나는 다음과 같이 읽고 Windows 문서에서 코드를 가지고 .ApplicationModel.VoiceCommands.VoiceCommandDefinition ". 내 질문은 다음과 같습니다.

내가 잘못된 장소에서 그렇게하고 있습니까? 이 프로젝트를 올바르게 수행하는 방법을 보여주는 예제 프로젝트를 알고 있습니까? (나는 Adventure Works를 들여다 보았지만,저기서이 줄을 찾지 못했습니다.) 아니면 내가 모르는 참고 문헌이 빠졌습니까?

+0

그 동안 AdventureWorks가 TripViewModel.UpdateDestinationPhraseList에서이 작업을 수행하고 있음을 알았습니다. – 7gegenTheben

답변

0
public async Task UpdateDestinationPhraseList() 
     { 
      try 
      { 
       // Update the destination phrase list, so that Cortana voice commands can use destinations added by users. 
       // When saving a trip, the UI navigates automatically back to this page, so the phrase list will be 
       // updated automatically. 
       VoiceCommandDefinition commandDefinitions; 

       string countryCode = CultureInfo.CurrentCulture.Name.ToLower(); 
       if(countryCode.Length == 0) 
       { 
        countryCode = "en-us"; 
       } 

       if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("AdventureWorksCommandSet_" + countryCode, out commandDefinitions)) 
       { 
        List<string> destinations = new List<string>(); 
        foreach (Model.Trip t in store.Trips) 
        { 
         destinations.Add(t.Destination); 
        } 

        await commandDefinitions.SetPhraseListAsync("destination", destinations); 
       } 
      } 
      catch (Exception ex) 
      { 
       System.Diagnostics.Debug.WriteLine("Updating Phrase list for VCDs: " + ex.ToString()); 
      } 
     }