protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) { BaseInputView input = (BaseInputView)item; if (input.DropDownTemplate != null) { return(DropDownTemplate); } if (input.MultiSelectTemplate != null) { return(MultiSelectTemplate); } if (input.TextTemplate != null) { switch (input.TextTemplate.TemplateName) { case "dateTemplate": return(DateTemplate); default: return(TextTemplate); } } return(TextTemplate); }
private Dictionary <string, object> GetRecognitionResults(BaseInputView inputView) { Type itemType = inputView.ItemsSource.GetType().GenericTypeArguments[0]; return(inputView.ItemsSource .Select(o => { return new { val = itemType.GetProperty(inputView.DropDownTemplate.ValueField).GetValue(o), text = (string)itemType.GetProperty(inputView.DropDownTemplate.TextField).GetValue(o) }; }).ToDictionary(k => k.text, v => v.val)); }
async Task DoNext(SpeechRecognitionResult result) { if (!this.RecognitionResults.ContainsKey(result.Text)) { #if (DEBUG) await Helpers.ShowDialog(result.Text + " " + Enum.GetName(typeof(SpeechRecognitionConfidence), result.Confidence)); #endif return; } BaseInputView inputView = this.ScreenSettings.Settings.GetAllQuestions().First(); PropertyInfo prop = inputView.GetType().GetProperty("CurrentValue", BindingFlags.Public | BindingFlags.Instance); if (null != prop && prop.CanWrite) { prop.SetValue(inputView, Convert.ChangeType(this.RecognitionResults[result.Text], inputView.Type), null); } else { return; } await DoNext(Buttons[0].ShortString, Buttons[0].Cancel); }