예제 #1
0
        public static FrameworkElement Render(AdaptiveTimeInput input, AdaptiveRenderContext context)
        {
            if (!context.Config.SupportsInteractivity)
            {
                AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;

                return(context.Render(textBlock));
            }

            TimePicker timePicker = new TimePicker
            {
                DataContext = input,
                ToolTip     = input.Placeholder,
                Style       = context.GetStyle("Adaptive.Input.Time"),
                Is24Hours   = true
            };

            if (DateTime.TryParse(input.Value, out DateTime value))
            {
                timePicker.SelectedTime = value;
            }

            context.InputBindings.Add(input.Id, () => timePicker.SelectedTime?.ToString("HH:mm") ?? "");

            return(timePicker);
        }
예제 #2
0
 public static FrameworkElement Render(AdaptiveTimeInput input, AdaptiveRenderContext context)
 {
     if (context.Config.SupportsInteractivity)
     {
         var      timePicker = new TimePicker();
         DateTime value;
         if (IsSupportedTimeFormat(input.Value) && DateTime.TryParse(input.Value, out value))
         {
             timePicker.Value = value;
         }
         TimeSpan minValue;
         if (IsSupportedTimeFormat(input.Min) && TimeSpan.TryParse(input.Min, out minValue))
         {
             timePicker.EndTime = minValue;
         }
         TimeSpan maxValue;
         if (IsSupportedTimeFormat(input.Max) && TimeSpan.TryParse(input.Max, out maxValue))
         {
             timePicker.EndTime = maxValue;
         }
         timePicker.Watermark   = input.Placeholder;
         timePicker.Style       = context.GetStyle("Adaptive.Input.Time");
         timePicker.DataContext = input;
         context.InputBindings.Add(input.Id, () => ToIso8601Time(timePicker.Text));
         return(timePicker);
     }
     else
     {
         var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
         textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
         return(context.Render(textBlock));
     }
 }
 public static FrameworkElement Render(AdaptiveTimeInput input, AdaptiveRenderContext context)
 {
     if (context.Config.SupportsInteractivity)
     {
         var textBox = new TextBox()
         {
             Text = input.Value
         };
         textBox.SetPlaceholder(input.Placeholder);
         textBox.Style = context.GetStyle($"Adaptive.Input.Text.Time");
         textBox.SetContext(input);
         context.InputBindings.Add(input.Id, () => textBox.Text);
         return(textBox);
     }
     else
     {
         AdaptiveContainer container = AdaptiveTypedElementConverter.CreateElement <AdaptiveContainer>();
         container.Spacing   = input.Spacing;
         container.Separator = input.Separator;
         AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
         textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
         container.Items.Add(textBlock);
         if (input.Value != null)
         {
             textBlock       = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
             textBlock.Text  = input.Value;
             textBlock.Color = AdaptiveTextColor.Accent;
             textBlock.Wrap  = true;
             container.Items.Add(textBlock);
         }
         return(context.Render(container));
     }
 }
예제 #4
0
        public static FrameworkElement Render(AdaptiveNumberInput input, AdaptiveRenderContext context)
        {
            if (context.Config.SupportsInteractivity)
            {
                IntegerUpDown numberPicker = new IntegerUpDown();
                // numberPicker.ShowButtonSpinner = true;

                if (!Double.IsNaN(input.Value))
                {
                    numberPicker.Value = Convert.ToInt32(input.Value);
                }

                if (!Double.IsNaN(input.Min))
                {
                    numberPicker.Minimum = Convert.ToInt32(input.Min);
                }

                if (!Double.IsNaN(input.Max))
                {
                    numberPicker.Minimum = Convert.ToInt32(input.Max);
                }

                numberPicker.Watermark   = input.Placeholder;
                numberPicker.Style       = context.GetStyle("Adaptive.Input.Number");
                numberPicker.DataContext = input;
                context.InputBindings.Add(input.Id, () => numberPicker.Value?.ToString());
                return(numberPicker);
            }
            else
            {
                var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
예제 #5
0
        public static FrameworkElement Render(AdaptiveTextInput input, AdaptiveRenderContext context)
        {
            if (context.Config.SupportsInteractivity)
            {
                var textBox = new WatermarkTextBox()
                {
                    Text = input.Value
                };
                if (input.IsMultiline == true)
                {
                    textBox.AcceptsReturn = true;
                    textBox.TextWrapping  = TextWrapping.Wrap;
                    textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                }
                if (input.MaxLength > 0)
                {
                    textBox.MaxLength = input.MaxLength;
                }

                textBox.Watermark   = input.Placeholder;
                textBox.Style       = context.GetStyle($"Adaptive.Input.Text.{input.Style}");
                textBox.DataContext = input;
                context.InputBindings.Add(input.Id, () => textBox.Text);
                return(textBox);
            }
            else
            {
                var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
예제 #6
0
 public static FrameworkElement Render(AdaptiveDateInput input, AdaptiveRenderContext context)
 {
     if (context.Config.SupportsInteractivity)
     {
         var datePicker = new DatePicker();
         datePicker.ToolTip = input.Placeholder;
         DateTime value;
         if (DateTime.TryParse(input.Value, out value))
         {
             datePicker.SelectedDate = value;
         }
         DateTime minValue;
         if (DateTime.TryParse(input.Min, out minValue))
         {
             datePicker.DisplayDateStart = minValue;
         }
         DateTime maxValue;
         if (DateTime.TryParse(input.Max, out maxValue))
         {
             datePicker.DisplayDateEnd = maxValue;
         }
         datePicker.Style       = context.GetStyle("Adaptive.Input.Date");
         datePicker.DataContext = input;
         context.InputBindings.Add(input.Id, () => ToIso8601Date(datePicker.Text));
         return(datePicker);
     }
     else
     {
         var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
         textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
         return(context.Render(textBlock));
     }
 }
예제 #7
0
        public static FrameworkElement Render(AdaptiveToggleInput input, AdaptiveRenderContext context)
        {
            if (context.Config.SupportsInteractivity)
            {
                var uiToggle = new CheckBox();

                uiToggle.Content = input.Title;
                uiToggle.SetState(input.Value == (input.ValueOn ?? "true"));
                uiToggle.Style = context.GetStyle($"Adaptive.Input.Toggle");
                uiToggle.SetContext(input);
                context.InputBindings.Add(input.Id, () => uiToggle.GetState() == true ? input.ValueOn ?? "true" : input.ValueOff ?? "false");
                return(uiToggle);
            }
            else
            {
                AdaptiveContainer container = AdaptiveTypedElementConverter.CreateElement <AdaptiveContainer>();
                container.Spacing   = input.Spacing;
                container.Separator = input.Separator;

                AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input);
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                    textBlock.Text  = (input.Value == (input.ValueOn ?? "true")) ? input.ValueOn ?? "selected" : input.ValueOff ?? "not selected";
                    textBlock.Color = AdaptiveTextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
예제 #8
0
        public View Render(AdaptiveTypedElement element)
        {
            if (!this.Config.SupportsInteractivity)
            {
                AdaptiveInput adaptiveInput  = element as AdaptiveInput;
                AdaptiveInput adaptiveInput1 = adaptiveInput;
                if (adaptiveInput != null)
                {
                    AdaptiveTextBlock nonInteractiveValue = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>(null);
                    nonInteractiveValue.Text  = adaptiveInput1.GetNonInteractiveValue() ?? "*[Input]*";
                    nonInteractiveValue.Color = AdaptiveTextColor.Accent;
                    nonInteractiveValue.Wrap  = true;
                    this.Warnings.Add(new AdaptiveWarning(-1, string.Format("Rendering non-interactive input element '{0}'", element.Type)));
                    return(this.Render(nonInteractiveValue));
                }
            }
            Func <AdaptiveTypedElement, AdaptiveRenderContext, View> func = this.ElementRenderers.Get(element.GetType());

            if (func != null)
            {
                return(func(element, this));
            }
            this.Warnings.Add(new AdaptiveWarning(-1, string.Format("No renderer for element '{0}'", element.Type)));
            return(null);
        }
예제 #9
0
        public static FrameworkElement Render(AdaptiveTextInput input, AdaptiveRenderContext context)
        {
            if (context.Config.SupportsInteractivity)
            {
                var textBox = new WatermarkTextBox()
                {
                    Text = input.Value
                };
                if (input.IsMultiline == true)
                {
                    textBox.AcceptsReturn = true;
                    textBox.TextWrapping  = TextWrapping.Wrap;
                    textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                }
                if (input.MaxLength > 0)
                {
                    textBox.MaxLength = input.MaxLength;
                }

                textBox.Watermark   = input.Placeholder;
                textBox.Style       = context.GetStyle($"Adaptive.Input.Text.{input.Style}");
                textBox.DataContext = input;
                context.InputBindings.Add(input.Id, () => textBox.Text);
                if (input.InlineAction != null)
                {
                    if (context.Config.Actions.ShowCard.ActionMode == ShowCardActionMode.Inline &&
                        input.InlineAction.GetType() == typeof(AdaptiveShowCardAction))
                    {
                        context.Warnings.Add(new AdaptiveWarning(-1, "Inline ShowCard not supported for InlineAction"));
                    }
                    else
                    {
                        if (context.Config.SupportsInteractivity && context.ActionHandlers.IsSupported(input.InlineAction.GetType()))
                        {
                            return(AdaptiveTextInputRenderer.RenderInlineAction(input, context, textBox));
                        }
                    }
                }
                return(textBox);
            }
            else
            {
                var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
예제 #10
0
        public static FrameworkElement Render(AdaptiveTextInput input, AdaptiveRenderContext context)
        {
            if (context.Config.SupportsInteractivity)
            {
                var textBox = new TextBox()
                {
                    Text = input.Value
                };
                if (input.IsMultiline == true)
                {
                    textBox.AcceptsReturn = true;

                    textBox.TextWrapping = TextWrapping.Wrap;
                    textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                }

                if (input.MaxLength > 0)
                {
                    textBox.MaxLength = input.MaxLength;
                }

                textBox.SetPlaceholder(input.Placeholder);
                textBox.Style = context.GetStyle($"Adaptive.Input.Text.{input.Style}");
                textBox.SetContext(input);
                context.InputBindings.Add(input.Id, () => textBox.Text);
                return(textBox);
            }
            else
            {
                AdaptiveContainer container = AdaptiveTypedElementConverter.CreateElement <AdaptiveContainer>();
                container.Spacing   = input.Spacing;
                container.Separator = input.Separator;
                AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                    textBlock.Text  = input.Value;
                    textBlock.Color = AdaptiveTextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
예제 #11
0
        /// <summary>
        /// Helper to deal with casting
        /// </summary>
        public FrameworkElement Render(AdaptiveTypedElement element)
        {
            // Inputs should render read-only if interactivity is false
            if (!Config.SupportsInteractivity && element is AdaptiveInput input)
            {
                var tb = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                tb.Text  = input.GetNonInteractiveValue() ?? "*[Input]*";
                tb.Color = AdaptiveTextColor.Accent;
                tb.Wrap  = true;
                Warnings.Add(new AdaptiveWarning(-1, $"Rendering non-interactive input element '{element.Type}'"));
                return(Render(tb));
            }

            var renderer = ElementRenderers.Get(element.GetType());

            if (renderer != null)
            {
                // Increment card depth before rendering the inner card
                if (element is AdaptiveCard)
                {
                    CardDepth += 1;
                }

                var rendered = renderer.Invoke(element, this);

                if (!String.IsNullOrEmpty(element.Id))
                {
                    rendered.Name = element.Id;
                }

                // Decrement card depth after inner card is rendered
                if (element is AdaptiveCard)
                {
                    CardDepth -= 1;
                }

                return(rendered);
            }

            Warnings.Add(new AdaptiveWarning(-1, $"No renderer for element '{element.Type}'"));
            return(null);
        }
        /// <summary>
        /// Helper to deal with casting
        /// </summary>
        public FrameworkElement Render(AdaptiveTypedElement element)
        {
            // Inputs should render read-only if interactivity is false
            if (!Config.SupportsInteractivity && element is AdaptiveInput input)
            {
                var tb = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                tb.Text  = input.GetNonInteractiveValue() ?? "*[Input]*";
                tb.Color = AdaptiveTextColor.Accent;
                tb.Wrap  = true;
                Warnings.Add(new AdaptiveWarning(-1, $"Rendering non-interactive input element '{element.Type}'"));
                return(Render(tb));
            }

            var renderer = ElementRenderers.Get(element.GetType());

            if (renderer != null)
            {
                return(renderer.Invoke(element, this));
            }

            Warnings.Add(new AdaptiveWarning(-1, $"No renderer for element '{element.Type}'"));
            return(null);
        }
예제 #13
0
        public static FrameworkElement Render(AdaptiveDateInput input, AdaptiveRenderContext context)
        {
            if (!context.Config.SupportsInteractivity)
            {
                AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;

                return(context.Render(textBlock));
            }

            DatePicker datePicker = new DatePicker
            {
                DataContext = input,
                ToolTip     = input.Placeholder,
                Style       = context.GetStyle("Adaptive.Input.Date")
            };


            if (DateTime.TryParse(input.Value, out DateTime value))
            {
                datePicker.SelectedDate = value;
            }

            if (DateTime.TryParse(input.Min, out DateTime minValue))
            {
                datePicker.DisplayDateStart = minValue;
            }

            if (DateTime.TryParse(input.Max, out DateTime maxValue))
            {
                datePicker.DisplayDateEnd = maxValue;
            }

            context.InputBindings.Add(input.Id, () => datePicker.SelectedDate?.ToString("yyyy-MM-dd") ?? "");

            return(datePicker);
        }
예제 #14
0
        /// <summary>
        /// Helper to deal with casting
        /// </summary>
        public FrameworkElement Render(AdaptiveTypedElement element)
        {
            FrameworkElement frameworkElementOut = null;
            var oldAncestorHasFallback           = AncestorHasFallback;
            var elementHasFallback = element != null && element.Fallback != null && (element.Fallback.Type != AdaptiveFallbackElement.AdaptiveFallbackType.None);

            AncestorHasFallback = AncestorHasFallback || elementHasFallback;

            try
            {
                if (AncestorHasFallback && !element.MeetsRequirements(FeatureRegistration))
                {
                    throw new AdaptiveFallbackException("Element requirements aren't met");
                }

                // Inputs should render read-only if interactivity is false
                if (!Config.SupportsInteractivity && element is AdaptiveInput input)
                {
                    var tb = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                    tb.Text  = input.GetNonInteractiveValue() ?? "*[Input]*";
                    tb.Color = AdaptiveTextColor.Accent;
                    tb.Wrap  = true;
                    Warnings.Add(new AdaptiveWarning(-1, $"Rendering non-interactive input element '{element.Type}'"));
                    frameworkElementOut = Render(tb);
                }

                if (frameworkElementOut == null)
                {
                    var renderer = ElementRenderers.Get(element.GetType());
                    if (renderer != null)
                    {
                        var rendered = renderer.Invoke(element, this);

                        if (!String.IsNullOrEmpty(element.Id))
                        {
                            rendered.Name = element.Id;
                        }

                        frameworkElementOut = rendered;
                    }
                }
            }
            catch (AdaptiveFallbackException)
            {
                if (!elementHasFallback)
                {
                    throw;
                }
            }

            if (frameworkElementOut == null)
            {
                // Since no renderer exists for this element, add warning and render fallback (if available)
                if (element.Fallback != null && element.Fallback.Type != AdaptiveFallbackElement.AdaptiveFallbackType.None)
                {
                    if (element.Fallback.Type == AdaptiveFallbackElement.AdaptiveFallbackType.Drop)
                    {
                        Warnings.Add(new AdaptiveWarning(-1, $"Dropping element '{element.Type}' for fallback"));
                    }
                    else if (element.Fallback.Type == AdaptiveFallbackElement.AdaptiveFallbackType.Content && element.Fallback.Content != null)
                    {
                        // Render fallback content
                        Warnings.Add(new AdaptiveWarning(-1, $"Performing fallback for '{element.Type}' (fallback element type '{element.Fallback.Content.Type}')"));
                        RenderingFallback   = true;
                        frameworkElementOut = Render(element.Fallback.Content);
                        RenderingFallback   = false;
                    }
                }
                else if (AncestorHasFallback && !RenderingFallback)
                {
                    throw new AdaptiveFallbackException();
                }
                else
                {
                    Warnings.Add(new AdaptiveWarning(-1, $"No renderer for element '{element.Type}'"));
                }
            }

            AncestorHasFallback = oldAncestorHasFallback;
            return(frameworkElementOut);
        }
예제 #15
0
        public static FrameworkElement Render(AdaptiveTextInput input, AdaptiveRenderContext context)
        {
            if (context.Config.SupportsInteractivity)
            {
                var textBox = new WatermarkTextBox()
                {
                    Text = input.Value
                };
                if (input.IsMultiline == true)
                {
                    textBox.AcceptsReturn = true;
                    textBox.TextWrapping  = TextWrapping.Wrap;
                    textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                }
                if (input.MaxLength > 0)
                {
                    textBox.MaxLength = input.MaxLength;
                }

                textBox.Watermark   = input.Placeholder;
                textBox.Style       = context.GetStyle($"Adaptive.Input.Text.{input.Style}");
                textBox.DataContext = input;
                context.InputBindings.Add(input.Id, () => textBox.Text);
                if (input.InlineAction != null)
                {
                    if (context.Config.Actions.ShowCard.ActionMode == ShowCardActionMode.Inline &&
                        input.InlineAction.GetType() == typeof(AdaptiveShowCardAction))
                    {
                        context.Warnings.Add(new AdaptiveWarning(-1, "Inline ShowCard not supported for InlineAction"));
                    }
                    else
                    {
                        if (context.Config.SupportsInteractivity && context.ActionHandlers.IsSupported(input.InlineAction.GetType()))
                        {
                            // Set up a parent view that holds textbox, separator and button
                            var parentView = new Grid();

                            // grid config for textbox
                            parentView.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = new GridLength(1, GridUnitType.Star)
                            });
                            Grid.SetColumn(textBox, 0);
                            parentView.Children.Add(textBox);

                            // grid config for spacing
                            int spacing = context.Config.GetSpacing(AdaptiveSpacing.Default);
                            var uiSep   = new Grid
                            {
                                Style             = context.GetStyle($"Adaptive.Input.Text.InlineAction.Separator"),
                                VerticalAlignment = VerticalAlignment.Stretch,
                                Width             = spacing,
                            };
                            parentView.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = new GridLength(spacing, GridUnitType.Pixel)
                            });
                            Grid.SetColumn(uiSep, 1);

                            // adding button
                            var   uiButton = new Button();
                            Style style    = context.GetStyle($"Adaptive.Input.Text.InlineAction.Button");
                            if (style != null)
                            {
                                uiButton.Style = style;
                            }

                            // this textblock becomes tooltip if icon url exists else becomes the tile for the button
                            var uiTitle = new TextBlock
                            {
                                Text = input.InlineAction.Title,
                            };

                            if (input.InlineAction.IconUrl != null)
                            {
                                var actionsConfig = context.Config.Actions;

                                var image = new AdaptiveImage(input.InlineAction.IconUrl)
                                {
                                    HorizontalAlignment = AdaptiveHorizontalAlignment.Center,
                                    Type = "Adaptive.Input.Text.InlineAction.Image",
                                };

                                FrameworkElement uiIcon = null;
                                uiIcon           = AdaptiveImageRenderer.Render(image, context);
                                uiButton.Content = uiIcon;

                                // adjust height
                                textBox.Loaded += (sender, e) =>
                                {
                                    uiIcon.Height = textBox.ActualHeight;
                                };

                                uiButton.ToolTip = uiTitle;
                            }
                            else
                            {
                                uiTitle.FontSize = context.Config.GetFontSize(AdaptiveFontStyle.Default, AdaptiveTextSize.Default);
                                uiTitle.Style    = context.GetStyle($"Adaptive.Input.Text.InlineAction.Title");
                                uiButton.Content = uiTitle;
                            }

                            uiButton.Click += (sender, e) =>
                            {
                                context.InvokeAction(uiButton, new AdaptiveActionEventArgs(input.InlineAction));

                                // Prevent nested events from triggering
                                e.Handled = true;
                            };

                            parentView.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = GridLength.Auto
                            });
                            Grid.SetColumn(uiButton, 2);
                            parentView.Children.Add(uiButton);
                            uiButton.VerticalAlignment = VerticalAlignment.Bottom;

                            textBox.KeyDown += (sender, e) =>
                            {
                                if (e.Key == System.Windows.Input.Key.Enter)
                                {
                                    context.InvokeAction(uiButton, new AdaptiveActionEventArgs(input.InlineAction));
                                    e.Handled = true;
                                }
                            };
                            return(parentView);
                        }
                    }
                }
                return(textBox);
            }
            else
            {
                var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
        public static FrameworkElement Render(AdaptiveChoiceSetInput input, AdaptiveRenderContext context)
        {
            var chosen = input.Value?.Split(',').Select(p => p.Trim()).Where(s => !string.IsNullOrEmpty(s)).ToList() ?? new List <string>();

            if (context.Config.SupportsInteractivity)
            {
                var uiGrid = new Grid();
                uiGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                uiGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });

                var uiComboBox = new ComboBox();
                uiComboBox.Style       = context.GetStyle("Adaptive.Input.AdaptiveChoiceSetInput.ComboBox");
                uiComboBox.DataContext = input;

                var uiChoices = new ListBox();
                ScrollViewer.SetHorizontalScrollBarVisibility(uiChoices, ScrollBarVisibility.Disabled);
                var itemsPanelTemplate = new ItemsPanelTemplate();
                var factory            = new FrameworkElementFactory(typeof(WrapPanel));
                itemsPanelTemplate.VisualTree = factory;
                uiChoices.ItemsPanel          = itemsPanelTemplate;
                uiChoices.DataContext         = input;
                uiChoices.Style = context.GetStyle("Adaptive.Input.AdaptiveChoiceSetInput");

                foreach (var choice in input.Choices)
                {
                    if (input.IsMultiSelect == true)
                    {
                        var uiCheckbox = new CheckBox();
                        uiCheckbox.Content     = choice.Title;
                        uiCheckbox.IsChecked   = chosen.Contains(choice.Value);
                        uiCheckbox.DataContext = choice;
                        uiCheckbox.Style       = context.GetStyle("Adaptive.Input.AdaptiveChoiceSetInput.CheckBox");
                        uiChoices.Items.Add(uiCheckbox);
                    }
                    else
                    {
                        if (input.Style == AdaptiveChoiceInputStyle.Compact)
                        {
                            var uiComboItem = new ComboBoxItem();
                            uiComboItem.Style       = context.GetStyle("Adaptive.Input.AdaptiveChoiceSetInput.ComboBoxItem");
                            uiComboItem.Content     = choice.Title;
                            uiComboItem.DataContext = choice;
                            uiComboBox.Items.Add(uiComboItem);
                            if (chosen.Contains(choice.Value))
                            {
                                uiComboBox.SelectedItem = uiComboItem;
                            }
                        }
                        else
                        {
                            var uiRadio = new RadioButton();
                            uiRadio.Content     = choice.Title;
                            uiRadio.IsChecked   = chosen.Contains(choice.Value);
                            uiRadio.GroupName   = input.Id;
                            uiRadio.DataContext = choice;
                            uiRadio.Style       = context.GetStyle("Adaptive.Input.AdaptiveChoiceSetInput.Radio");
                            uiChoices.Items.Add(uiRadio);
                        }
                    }
                }
                context.InputBindings.Add(input.Id, () =>
                {
                    if (input.IsMultiSelect == true)
                    {
                        string values = string.Empty;
                        foreach (var item in uiChoices.Items)
                        {
                            CheckBox checkBox             = (CheckBox)item;
                            AdaptiveChoice adaptiveChoice = checkBox.DataContext as AdaptiveChoice;
                            if (checkBox.IsChecked == true)
                            {
                                values += (values == string.Empty ? "" : ",") + adaptiveChoice.Value;
                            }
                        }
                        return(values);
                    }
                    else
                    {
                        if (input.Style == AdaptiveChoiceInputStyle.Compact)
                        {
                            ComboBoxItem item = uiComboBox.SelectedItem as ComboBoxItem;
                            if (item != null)
                            {
                                AdaptiveChoice adaptiveChoice = item.DataContext as AdaptiveChoice;
                                return(adaptiveChoice.Value);
                            }
                            return(null);
                        }
                        else
                        {
                            foreach (var item in uiChoices.Items)
                            {
                                RadioButton radioBox          = (RadioButton)item;
                                AdaptiveChoice adaptiveChoice = radioBox.DataContext as AdaptiveChoice;
                                if (radioBox.IsChecked == true)
                                {
                                    return(adaptiveChoice.Value);
                                }
                            }
                            return(null);
                        }
                    }
                });
                if (input.Style == AdaptiveChoiceInputStyle.Compact)
                {
                    Grid.SetRow(uiComboBox, 1);
                    uiGrid.Children.Add(uiComboBox);
                    return(uiGrid);
                }
                else
                {
                    Grid.SetRow(uiChoices, 1);
                    uiGrid.Children.Add(uiChoices);
                    return(uiGrid);
                }
            }

            string choiceText = XamlUtilities.GetFallbackText(input);

            if (choiceText == null)
            {
                List <string> choices = input.Choices.Select(choice => choice.Title).ToList();
                if (input.Style == AdaptiveChoiceInputStyle.Compact)
                {
                    if (input.IsMultiSelect)
                    {
                        choiceText = $"Choices: {RendererUtilities.JoinString(choices, ", ", " and ")}";
                    }
                    else
                    {
                        choiceText = $"Choices: {RendererUtilities.JoinString(choices, ", ", " or ")}";
                    }
                }
                else // if (adaptiveChoiceSetInput.Style == ChoiceInputStyle.Expanded)
                {
                    choiceText = $"* {RendererUtilities.JoinString(choices, "\n* ", "\n* ")}";
                }
            }
            AdaptiveContainer container = AdaptiveTypedElementConverter.CreateElement <AdaptiveContainer>();

            container.Spacing   = input.Spacing;
            container.Separator = input.Separator;
            AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();

            textBlock.Text = choiceText;
            textBlock.Wrap = true;
            container.Items.Add(textBlock);

            textBlock       = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
            textBlock.Text  = RendererUtilities.JoinString(input.Choices.Where(c => chosen.Contains(c.Value)).Select(c => c.Title).ToList(), ", ", " and ");
            textBlock.Color = AdaptiveTextColor.Accent;
            textBlock.Wrap  = true;
            container.Items.Add(textBlock);
            return(context.Render(container));
        }