示例#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(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);
        }