使用Xamarin表单创建动态表单

我有一个包含对象的列表。这些对象都具有属性。我在后面的代码中遍历此列表。根据每个项目的特定属性,我决定应该创建哪个视图。

可以是按钮,选择器等。此刻,我已经从服务器到达UI。但是现在我需要从UI返回到服务器,我认为我需要为此绑定,但是我无法完成。我该如何实现?

我的代码:

        var stack = new StackLayout()
        {
            Orientation = StackOrientation.Vertical,Padding = 5
        };

        for (int i = 0; i < (BindingContext as ChecklistEditViewModel).ChecklistItems.Count; i++)
        {
            var item = (BindingContext as ChecklistEditViewModel).ChecklistItems[i];

            var description = new Label();
            description.Text = item.Description;
            stack.Children.Add(description);

            if ((item.ChecklistItemType == Domain.ChecklistItemType.Number))
            {
                var numerEntry = new Entry();
                numerEntry.Keyboard = Keyboard.Numeric;
                stack.Children.Add(numerEntry);
            }
        }

        Content = stack;
RERR555 回答:使用Xamarin表单创建动态表单

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2611810.html

大家都在问