public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            DateInput input = (DateInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var textBox = new TextBox()
                {
                    Text = input.Value
                };
                textBox.SetPlaceholder(input.Placeholder);
                textBox.Style = context.GetStyle($"Adaptive.Input.Text.Date");
                textBox.SetContext(input);
                context.InputBindings.Add(input.Id, () => textBox.Text);
                return(textBox);
            }
            else
            {
                Container container = TypedElementConverter.CreateElement <Container>();
                container.Separation = input.Separation;
                TextBlock textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = TypedElementConverter.CreateElement <TextBlock>();
                    textBlock.Text  = input.Value;
                    textBlock.Color = TextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
        public static FrameworkElement Render(TextInput input, RenderContext 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 = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            TimeInput input = (TimeInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var      timePicker = new TimePicker();
                DateTime value;
                if (DateTime.TryParse(input.Value, out value))
                {
                    timePicker.Value = value;
                }
                TimeSpan minValue;
                if (TimeSpan.TryParse(input.Min, out minValue))
                {
                    timePicker.EndTime = minValue;
                }
                TimeSpan maxValue;
                if (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, () => timePicker.Text);
                return(timePicker);
            }
            else
            {
                var textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
        public static FrameworkElement Render(Container container, RenderContext context)
        {
            var containerStyle = context.Config.ContainerStyles.Default;
            var uiContainer    = new Grid();

            uiContainer.Margin = new Thickness(context.Config.Spacing.Padding);
            uiContainer.Style  = context.GetStyle("Adaptive.Container");
            AddContainerElements(uiContainer, container.Items, context);

            if (container.SelectAction != null)
            {
                var uiButton = (Button)context.Render(container.SelectAction);//, new RenderContext(container.actionCallback, container.missingDataCallback));
                if (uiButton != null)
                {
                    uiButton.Content = uiContainer;
                    uiButton.Style   = context.GetStyle("Adaptive.Action.Tap");
                    return(uiButton);
                }
            }

#if WPF
            Grid uiOuterContainer = new Grid();
            uiOuterContainer.Background = context.GetColorBrush(containerStyle.BackgroundColor);
            uiOuterContainer.Children.Add(uiContainer);
            Border border = new Border();
            border.Child = uiOuterContainer;
            return(border);
#else
            // TODO for xamarin
            return(uiContainer);
#endif
        }
Beispiel #5
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            DateInput input = (DateInput)element;

            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, () => datePicker.Text);
                return(datePicker);
            }
            else
            {
                var textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
        public static FrameworkElement Render(NumberInput input, RenderContext 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 = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
Beispiel #7
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            TextInput input = (TextInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var textBox = new TextBox()
                {
                    Text = input.Value
                };
                if (input.IsMultiline == true)
                {
                    textBox.AcceptsReturn = true;
#if WPF
                    textBox.TextWrapping = TextWrapping.Wrap;
                    textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
#elif XAMARIN
                    // TODO
#endif
                }
#if WPF
                if (input.MaxLength > 0)
                {
                    textBox.MaxLength = input.MaxLength;
                }
#elif XAMARIN
                // TODO
#endif
                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
            {
                Container container = TypedElementConverter.CreateElement <Container>();
                container.Separation = input.Separation;
                TextBlock textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = TypedElementConverter.CreateElement <TextBlock>();
                    textBlock.Text  = input.Value;
                    textBlock.Color = TextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
Beispiel #8
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            Image image   = (Image)element;
            var   uiImage = new UI.Image();

            uiImage.SetSource(image.Url, context);
            uiImage.SetHorizontalAlignment(image.HorizontalAlignment);


            string style = $"Adaptive.{image.Type}";

            if (image.Style == ImageStyle.Person)
            {
                style += $".{image.Style}";
#if WPF
                var mask = new RadialGradientBrush()
                {
                    GradientOrigin = new Point(0.5, 0.5),
                    Center         = new Point(0.5, 0.5),
                    RadiusX        = 0.5,
                    RadiusY        = 0.5,
                    GradientStops  = new GradientStopCollection()
                };
                mask.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#ffffffff"), .9));
                mask.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#00ffffff"), 1.0));
                uiImage.OpacityMask = mask;
#elif XAMARIN
                //TODO
#endif
            }
            uiImage.Style = context.GetStyle(style);
            uiImage.SetImageProperties(image, context);

            if (image.SelectAction != null)
            {
                var uiButton = (Button)context.Render(image.SelectAction);
                if (uiButton != null)
                {
                    uiButton.Content = uiImage;
                    uiButton.Style   = context.GetStyle("Adaptive.Action.Tap");
                    return(uiButton);
                }
            }
            return(uiImage);
        }
 public static void AddContainerElements(Grid uiContainer, List <CardElement> elements, RenderContext context)
 {
     foreach (var cardElement in elements)
     {
         // each element has a row
         FrameworkElement uiElement = context.Render(cardElement);
         if (uiElement != null)
         {
             if (cardElement.Separator && uiContainer.RowDefinitions.Count > 0)
             {
                 AddSeperator(context, cardElement, uiContainer);
             }
             uiContainer.RowDefinitions.Add(new RowDefinition()
             {
                 Height = GridLength.Auto
             });
             Grid.SetRow(uiElement, uiContainer.RowDefinitions.Count - 1);
             uiContainer.Children.Add(uiElement);
         }
     }
 }
Beispiel #10
0
        public static FrameworkElement Render(Column column, RenderContext context)
        {
            var uiContainer = new Grid();

            uiContainer.Style = context.GetStyle("Adaptive.Column");

            XamlContainer.AddContainerElements(uiContainer, column.Items, context);

            if (column.SelectAction != null)
            {
                var uiButton = (Button)context.Render(column.SelectAction);//, new RenderContext(this.actionCallback, this.missingDataCallback));
                if (uiButton != null)
                {
                    uiButton.Content = uiContainer;
                    uiButton.Style   = context.GetStyle("Adaptive.Action.Tap");
                    return(uiButton);
                }
            }

            return(uiContainer);
        }
Beispiel #11
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            ToggleInput input = (ToggleInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var uiToggle = new CheckBox();
#if WPF
                // TODO: Finish switch
                uiToggle.Content = input.Title;
#endif
                uiToggle.SetState(input.Value == (input.ValueOn ?? "true"));
                uiToggle.Style = context.GetStyle($"Adaptive.Input.Toggle");
                uiToggle.SetContext(input);
                context.InputBindings.Add(input.Id, () =>
                {
                    return(uiToggle.GetState() == true ? input.ValueOn ?? "true" : input.ValueOff ?? "false");
                });
                return(uiToggle);
            }
            else
            {
                Container container = TypedElementConverter.CreateElement <Container>();
                container.Separation = input.Separation;

                TextBlock textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input);
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = TypedElementConverter.CreateElement <TextBlock>();
                    textBlock.Text  = (input.Value == (input.ValueOn ?? "true")) ? input.ValueOn ?? "selected" : input.ValueOff ?? "not selected";
                    textBlock.Color = TextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
Beispiel #12
0
        public static void AddActions(Grid uiContainer, List <ActionBase> actions, RenderContext context)
        {
            var actionsToProcess = actions
                                   .Take(context.Config.Actions.MaxActions).ToList();

            if (!actionsToProcess.Any())
            {
                return;
            }

            // TODO: Bring back UniformGrid
            //var uiActionBar = new UniformGrid();

            var uiActionBar = new Grid();
            //uiActionBar.Rows = 1;
            //uiActionBar.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            //uiActionBar.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            int iCol = 0;

            foreach (var action in actionsToProcess)
            {
                // add actions
                var uiAction = context.Render(action);
                if (uiAction != null)
                {
                    Grid.SetColumn(uiAction, iCol++);
                    uiActionBar.Children.Add(uiAction);
                }
            }
            uiActionBar.Style = context.GetStyle("Adaptive.Actions");
            uiContainer.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            Grid.SetRow(uiActionBar, uiContainer.RowDefinitions.Count - 1);
            uiContainer.Children.Add(uiActionBar);
        }
Beispiel #13
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            ImageSet imageSet = (ImageSet)element;

#if WPF
            var uiImageSet = new ListBox();
            ScrollViewer.SetHorizontalScrollBarVisibility(uiImageSet, ScrollBarVisibility.Disabled);
            var itemsPanelTemplate = new ItemsPanelTemplate();
            var factory            = new FrameworkElementFactory(typeof(WrapPanel));
            // factory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            itemsPanelTemplate.VisualTree = factory;
            uiImageSet.ItemsPanel         = itemsPanelTemplate;
#elif XAMARIN
            var uiImageSet = new StackLayout {
                Orientation = StackOrientation.Vertical
            };
#endif

            uiImageSet.Style = context.GetStyle("Adaptive.ImageSet");
            foreach (var image in imageSet.Images)
            {
                if (image.Size == ImageSize.Auto)
                {
                    if (imageSet.ImageSize != ImageSize.Auto)
                    {
                        image.Size = imageSet.ImageSize;
                    }
                    else
                    {
                        image.Size = context.Config.ImageSet.ImageSize;
                    }
                }

                var uiImage = context.Render(image);
                uiImageSet.Add(uiImage);
            }
            return(uiImageSet);
        }
        public static void AddActions(Grid uiContainer, List <ActionBase> actions, RenderContext context)
        {
            var maxActions       = context.Config.Actions.MaxActions;
            var actionsToProcess = actions
                                   .Take(maxActions).ToList();

            if (actionsToProcess.Any() == true)
            {
                var uiActionBar = new UniformGrid();

                if (context.Config.Actions.ActionsOrientation == ActionsOrientation.Horizontal)
                {
                    uiActionBar.Columns = actionsToProcess.Count();
                }
                else
                {
                    uiActionBar.Rows = actionsToProcess.Count();
                }

                uiActionBar.HorizontalAlignment = (System.Windows.HorizontalAlignment)Enum.Parse(typeof(System.Windows.HorizontalAlignment), context.Config.Actions.ActionAlignment.ToString());
                uiActionBar.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                uiActionBar.Style = context.GetStyle("Adaptive.Actions");

                if (uiContainer.RowDefinitions.Count > 0)
                {
                    XamlContainer.AddSeperator(context, new Container(), uiContainer);
                }
                uiContainer.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                Grid.SetRow(uiActionBar, uiContainer.RowDefinitions.Count - 1);
                uiContainer.Children.Add(uiActionBar);

                bool isInline = (context.Config.Actions.ShowCard.ActionMode == ShowCardActionMode.Inline);

                if (isInline &&
                    actionsToProcess.Where(a => a is ShowCardAction).Any())
                {
                    uiContainer.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });
                }

                int iPos = 0;
                List <FrameworkElement> actionBarCards = new List <FrameworkElement>();
                foreach (var action in actionsToProcess)
                {
                    // add actions
                    var uiAction = (Button)context.Render(action);
                    if (uiAction != null)
                    {
                        if (uiActionBar.Children.Count > 0)
                        {
                            if (context.Config.Actions.ActionsOrientation == ActionsOrientation.Horizontal)
                            {
                                uiAction.Margin = new Thickness(context.Config.Actions.ButtonSpacing, 0, 0, 0);
                            }
                            else
                            {
                                uiAction.Margin = new Thickness(0, context.Config.Actions.ButtonSpacing, 0, 0);
                            }
                        }

                        if (context.Config.Actions.ActionsOrientation == ActionsOrientation.Horizontal)
                        {
                            Grid.SetColumn(uiAction, iPos++);
                        }

                        uiActionBar.Children.Add(uiAction);

                        if (action is ShowCardAction)
                        {
                            ShowCardAction showCardAction = (ShowCardAction)action;
                            if (isInline)
                            {
                                Grid uiShowCardContainer = new Grid();
                                uiShowCardContainer.Style       = context.GetStyle("Adaptive.Actions.ShowCard");
                                uiShowCardContainer.DataContext = showCardAction;
                                uiShowCardContainer.Margin      = new Thickness(0, context.Config.Actions.ShowCard.InlineTopMargin, 0, 0);
                                uiShowCardContainer.Visibility  = Visibility.Collapsed;

                                // render the card
                                var uiShowCard = context.Render(showCardAction.Card);
                                ((Grid)uiShowCard).Background = context.GetColorBrush("Transparent");
                                uiShowCard.DataContext        = showCardAction;
                                uiShowCardContainer.Children.Add(uiShowCard);

                                actionBarCards.Add(uiShowCardContainer);
                                Grid.SetRow(uiShowCardContainer, uiContainer.RowDefinitions.Count - 1);
                                uiContainer.Children.Add(uiShowCardContainer);

                                uiAction.Click += (sender, e) =>
                                {
                                    bool showCard = (uiShowCardContainer.Visibility != Visibility.Visible);
                                    foreach (var actionBarCard in actionBarCards)
                                    {
                                        actionBarCard.Visibility = Visibility.Collapsed;
                                    }
                                    if (showCard)
                                    {
                                        uiShowCardContainer.Visibility = Visibility.Visible;
                                    }
                                };
                            }
                        }
                    }
                }
            }
        }
Beispiel #15
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            FactSet factSet   = (FactSet)element;
            var     uiFactSet = new Grid();

            // grid.Margin = factSet.Theme.FactSetMargins;
            uiFactSet.Style = context.GetStyle("Adaptive.FactSet");

            uiFactSet.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            uiFactSet.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            int iRow = 0;

            foreach (var fact in factSet.Facts)
            {
                var uiTitle = context.Render(new TextBlock()
                {
                    Size     = context.Config.FactSet.Title.Size,
                    Color    = context.Config.FactSet.Title.Color,
                    IsSubtle = context.Config.FactSet.Title.IsSubtle,
                    Weight   = context.Config.FactSet.Title.Weight,
                    Wrap     = context.Config.FactSet.Title.Wrap,
                    Text     = fact.Title
                });
#if WPF
                uiTitle.Style  = context.GetStyle("Adaptive.Fact.Title");
                uiTitle.Margin = new Thickness(left: 0, top: 0, right: context.Config.FactSet.Spacing, bottom: 0);
#elif XAMARIN
                //TODO
#endif

                var uiValue = context.Render(new TextBlock()
                {
                    Size     = context.Config.FactSet.Value.Size,
                    Color    = context.Config.FactSet.Value.Color,
                    IsSubtle = context.Config.FactSet.Value.IsSubtle,
                    Weight   = context.Config.FactSet.Value.Weight,
                    Wrap     = context.Config.FactSet.Value.Wrap,
                    Text     = fact.Value
                });
#if WPF
                uiValue.Style = context.GetStyle("Adaptive.Fact.Value");
#elif XAMARIN
                //TODO
#endif

                uiFactSet.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });

                Grid.SetColumn(uiTitle, 0);
                Grid.SetRow(uiTitle, iRow);
                uiFactSet.Children.Add(uiTitle);

                Grid.SetColumn(uiValue, 1);
                Grid.SetRow(uiValue, iRow++);
                uiFactSet.Children.Add(uiValue);
            }
            return(uiFactSet);
        }
Beispiel #16
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            ColumnSet columnSet   = (ColumnSet)element;
            var       uiColumnSet = new Grid();

            uiColumnSet.Style = context.GetStyle($"Adaptive.{columnSet.Type}");

            foreach (var column in columnSet.Columns)
            {
                FrameworkElement uiContainer = context.Render(column);

                // Add vertical Seperator
                if (uiColumnSet.ColumnDefinitions.Count > 0)
                {
                    if (column.Separation != SeparationStyle.None)
                    {
                        var uiSep = new Grid();
                        uiSep.Style = context.GetStyle($"Adaptive.VerticalSeparator");
#if WPF
                        uiSep.VerticalAlignment = VerticalAlignment.Stretch;
#elif XAMARIN
                        // TOOD: check xamarin separator visual
                        //sep.VerticalAlignment = VerticalAlignment.Stretch;
#endif
                        SeparationConfig sepStyle;
                        switch (column.Separation)
                        {
                        case SeparationStyle.Strong:
                            sepStyle = context.Config.GetSeparationForElement(element, true);
                            break;

                        case SeparationStyle.Default:
                        default:
                            sepStyle = context.Config.GetSeparationForElement(element, false);
                            break;
                        }
                        uiSep.Margin = new Thickness(sepStyle.Spacing / 2, 0, sepStyle.Spacing / 2, 0);
#if WPF
                        uiSep.Width = sepStyle.LineThickness;
                        if (sepStyle.LineColor != null)
                        {
                            uiSep.Background = context.GetColorBrush(sepStyle.LineColor);
                        }
#elif XAMARIN
                        // TODO
#endif
                        uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = GridLength.Auto
                        });
                        Grid.SetColumn(uiSep, uiColumnSet.ColumnDefinitions.Count - 1);
                        uiColumnSet.Children.Add(uiSep);
                    }
                }


                // do some sizing magic using the magic GridUnitType.Star
                var size = column.Size?.ToLower();
                if (size == null || size == ColumnSize.Stretch.ToLower())
                {
                    uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    });
                }
                else if (size == ColumnSize.Auto.ToLower())
                {
                    uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });
                }
                else
                {
                    double val;
                    if (double.TryParse(size, out val))
                    {
                        uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = new GridLength(val, GridUnitType.Star)
                        });
                    }
                    else
                    {
                        uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = GridLength.Auto
                        });
                    }
                }

                Grid.SetColumn(uiContainer, uiColumnSet.ColumnDefinitions.Count - 1);
                uiColumnSet.Children.Add(uiContainer);
            }

            return(uiColumnSet);
        }
        public static FrameworkElement Render(ColumnSet columnSet, RenderContext context)
        {
            var uiColumnSet = new Grid();

            uiColumnSet.Style = context.GetStyle($"Adaptive.{columnSet.Type}");

            foreach (var column in columnSet.Columns)
            {
                FrameworkElement uiContainer = context.Render(column);

                // Add vertical Seperator
                if (uiColumnSet.ColumnDefinitions.Count > 0)
                {
                    if (column.Separator || column.Spacing != Spacing.None)
                    {
                        var uiSep = new Grid();
                        uiSep.Style = context.GetStyle($"Adaptive.VerticalSeparator");
#if WPF
                        uiSep.VerticalAlignment = VerticalAlignment.Stretch;
#elif XAMARIN
                        // TOOD: check xamarin separator visual
                        //sep.VerticalAlignment = VerticalAlignment.Stretch;
#endif
                        int spacing = context.Config.GetSpacing(column.Spacing);
                        uiSep.Margin = new Thickness(spacing / 2.0, 0, spacing / 2.0, 0);
#if WPF
                        uiSep.Width = context.Config.Separator.LineThickness;
                        if (column.Separator && context.Config.Separator.LineColor != null)
                        {
                            uiSep.Background = context.GetColorBrush(context.Config.Separator.LineColor);
                        }
#elif XAMARIN
                        // TODO
#endif
                        uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = GridLength.Auto
                        });
                        Grid.SetColumn(uiSep, uiColumnSet.ColumnDefinitions.Count - 1);
                        uiColumnSet.Children.Add(uiSep);
                    }
                }


                // do some sizing magic using the magic GridUnitType.Star
                var width = column.Width?.ToLower();
                if (string.IsNullOrEmpty(width))
#pragma warning disable CS0618 // Type or member is obsolete
                {
                    width = column.Size?.ToLower();
                }
#pragma warning restore CS0618 // Type or member is obsolete
                if (width == null || width == ColumnWidth.Stretch.ToLower())
                {
                    uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    });
                }
                else if (width == ColumnWidth.Auto.ToLower())
                {
                    uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });
                }
                else
                {
                    double val;
                    if (double.TryParse(width, out val))
                    {
                        uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = new GridLength(val, GridUnitType.Star)
                        });
                    }
                    else
                    {
                        uiColumnSet.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = GridLength.Auto
                        });
                    }
                }

                Grid.SetColumn(uiContainer, uiColumnSet.ColumnDefinitions.Count - 1);
                uiColumnSet.Children.Add(uiContainer);
            }

            if (columnSet.SelectAction != null)
            {
                var uiButton = (Button)context.Render(columnSet.SelectAction);
                if (uiButton != null)
                {
                    uiButton.Content = uiColumnSet;
                    uiButton.Style   = context.GetStyle("Adaptive.Action.Tap");
                    return(uiButton);
                }
            }
            return(uiColumnSet);
        }
        public static FrameworkElement Render(ChoiceSet choiceSet, RenderContext context)
        {
            var chosen = choiceSet.Value?.Split(',').Select(p => p.Trim()).Where(s => !string.IsNullOrEmpty(s)).ToList() ?? new List <string>();

#if WPF
            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.ChoiceSet.ComboBox");
                uiComboBox.DataContext = choiceSet;

                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         = choiceSet;
                uiChoices.Style = context.GetStyle("Adaptive.Input.ChoiceSet");

                foreach (var choice in choiceSet.Choices)
                {
                    if (choiceSet.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.ChoiceSet.CheckBox");
                        uiChoices.Items.Add(uiCheckbox);
                    }
                    else
                    {
                        if (choiceSet.Style == ChoiceInputStyle.Compact)
                        {
                            var uiComboItem = new ComboBoxItem();
                            uiComboItem.Style       = context.GetStyle("Adaptive.Input.ChoiceSet.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   = choiceSet.Id;
                            uiRadio.DataContext = choice;
                            uiRadio.Style       = context.GetStyle("Adaptive.Input.ChoiceSet.Radio");
                            uiChoices.Items.Add(uiRadio);
                        }
                    }
                }
                context.InputBindings.Add(choiceSet.Id, () =>
                {
                    if (choiceSet.IsMultiSelect == true)
                    {
                        string values = string.Empty;
                        foreach (var item in uiChoices.Items)
                        {
                            CheckBox checkBox = (CheckBox)item;
                            Choice choice     = checkBox.DataContext as Choice;
                            if (checkBox.IsChecked == true)
                            {
                                values += (values == string.Empty ? "" : ",") + choice.Value;
                            }
                        }
                        return(values);
                    }
                    else
                    {
                        if (choiceSet.Style == ChoiceInputStyle.Compact)
                        {
                            ComboBoxItem item = uiComboBox.SelectedItem as ComboBoxItem;
                            if (item != null)
                            {
                                Choice choice = item.DataContext as Choice;
                                return(choice.Value);
                            }
                            return(null);
                        }
                        else
                        {
                            foreach (var item in uiChoices.Items)
                            {
                                RadioButton radioBox = (RadioButton)item;
                                Choice choice        = radioBox.DataContext as Choice;
                                if (radioBox.IsChecked == true)
                                {
                                    return(choice.Value);
                                }
                            }
                            return(null);
                        }
                    }
                });
                if (choiceSet.Style == ChoiceInputStyle.Compact)
                {
                    Grid.SetRow(uiComboBox, 1);
                    uiGrid.Children.Add(uiComboBox);
                    return(uiGrid);
                }
                else
                {
                    Grid.SetRow(uiChoices, 1);
                    uiGrid.Children.Add(uiChoices);
                    return(uiGrid);
                }
            }
#endif

            string choiceText = XamlUtilities.GetFallbackText(choiceSet);
            if (choiceText == null)
            {
                List <string> choices = choiceSet.Choices.Select(choice => choice.Title).ToList();
                if (choiceSet.Style == ChoiceInputStyle.Compact)
                {
                    if (choiceSet.IsMultiSelect)
                    {
                        choiceText = $"Choices: {RendererUtilities.JoinString(choices, ", ", " and ")}";
                    }
                    else
                    {
                        choiceText = $"Choices: {RendererUtilities.JoinString(choices, ", ", " or ")}";
                    }
                }
                else // if (choiceSet.Style == ChoiceInputStyle.Expanded)
                {
                    choiceText = $"* {RendererUtilities.JoinString(choices, "\n* ", "\n* ")}";
                }
            }
            Container container = TypedElementConverter.CreateElement <Container>();
            container.Separation = choiceSet.Separation;
            TextBlock textBlock = TypedElementConverter.CreateElement <TextBlock>();
            textBlock.Text = choiceText;
            textBlock.Wrap = true;
            container.Items.Add(textBlock);

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