Exemplo n.º 1
0
        public void ChildrenAreSetByDataTemplateSelector()
        {
            var items        = GetItems();
            var repeaterView = new RepeaterView
            {
                ItemsSource  = items,
                ItemTemplate = new SelectableDataTemplateSelector()
            };

            for (var i = 0; i < items.Count(); i++)
            {
                var child   = repeaterView.Children[i];
                var context = child.BindingContext as ISelectable;

                Assert.NotNull(child);
                Assert.NotNull(context);

                if (context.IsSelected)
                {
                    Assert.IsType <IsSelectedViewMock>(child);
                }
                else
                {
                    Assert.IsType <IsNotSelectedViewMock>(child);
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.RepeaterViewLayout);

            _repeaterView = FindViewById <RepeaterView>(Resource.Id.repeaterView);
            _adapter      = new RepeaterViewAdapter();
            _repeaterView.SetAdapter(_adapter);
        }
Exemplo n.º 3
0
        public void ViewHasThreeChildren()
        {
            var items        = GetItems();
            var repeaterView = new RepeaterView
            {
                ItemsSource = items
            };

            Assert.Equal(items.Count(), repeaterView.Children.Count);
        }
Exemplo n.º 4
0
        private RepeaterView <PrayerRequestModel> GetRepeaterView()
        {
            var repeater = new RepeaterView <PrayerRequestModel>
            {
                ItemsSource  = ViewModel.PrayerRequestCollection,
                ItemTemplate = new DataTemplate(GetTemplate)
            };

            return(repeater);
        }
Exemplo n.º 5
0
        private View GetRepeaterView()
        {
            var repeater = new RepeaterView <EventModel>
            {
                ItemsSource  = ViewModel.Events,
                ItemTemplate = new DataTemplate(GetEventsTemplate)
            };

            var scrollView = new ScrollView()
            {
                Content = repeater
            };

            return(scrollView);
        }
Exemplo n.º 6
0
        private View GetRepeaterView()
        {
            var repeater = new RepeaterView <GroupingAmount>
            {
                Spacing      = 10,
                ItemTemplate = new DataTemplate(() =>
                {
                    var grid = new Grid();
                    grid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(50)
                    });
                    grid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    });

                    var labelCurrency      = new Label();
                    labelCurrency.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                    //labelCurrency.TextColor = Color.White;
                    labelCurrency.VerticalOptions = LayoutOptions.Center;
                    labelCurrency.SetBinding(Label.TextProperty, new Binding("Currency"));
                    Grid.SetColumn(labelCurrency, 0);

                    var labelAmount      = new Label();
                    labelAmount.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                    //labelAmount.TextColor = Color.White;
                    labelAmount.VerticalOptions = LayoutOptions.Center;
                    labelAmount.SetBinding(Label.TextProperty, new Binding("Amount", converter: new CurrencyConverter()));
                    Grid.SetColumn(labelAmount, 1);

                    grid.Children.Add(labelCurrency);
                    grid.Children.Add(labelAmount);

                    return(new ViewCell {
                        View = grid
                    });
                })
            };

            repeater.SetBinding(RepeaterView <GroupingAmount> .ItemsSourceProperty, new Binding("Amounts"));

            return(repeater);
        }
Exemplo n.º 7
0
        public void ChildrenHaveBindingContext()
        {
            var items        = GetItems();
            var repeaterView = new RepeaterView
            {
                ItemsSource = items
            };

            for (var i = 0; i < items.Count(); i++)
            {
                var child   = repeaterView.Children[i];
                var context = items[i];

                Assert.NotNull(child);
                Assert.NotNull(context);

                Assert.NotNull(child.BindingContext);
                Assert.Equal(context, child.BindingContext);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RepeaterViewPage"/> class.
        /// </summary>
        public RepeaterViewPage()
        {
            var viewModel = new RepeaterViewViewModel();

            BindingContext = viewModel;

            var repeater = new RepeaterView <Thing>
            {
                Spacing      = 10,
                ItemsSource  = viewModel.Things,
                ItemTemplate = new DataTemplate(() =>
                {
                    var nameLabel = new Label {
                        Font = Font.SystemFontOfSize(NamedSize.Medium)
                    };
                    nameLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsNamePropertyName);

                    var descriptionLabel = new Label {
                        Font = Font.SystemFontOfSize(NamedSize.Small)
                    };
                    descriptionLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsDescriptionPropertyName);

                    ViewCell cell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Spacing  = 0,
                            Children =
                            {
                                nameLabel,
                                descriptionLabel
                            }
                        }
                    };

                    return(cell);
                })
            };

            var removeButton = new Button
            {
                Text = "Remove 1st Item",
                HorizontalOptions = LayoutOptions.Start
            };

            removeButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.RemoveFirstItemCommandName);

            var addButton = new Button
            {
                Text = "Add New Item",
                HorizontalOptions = LayoutOptions.Start
            };

            addButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.AddItemCommandName);

            Content = new StackLayout
            {
                Padding  = 20,
                Spacing  = 5,
                Children =
                {
                    new Label
                    {
                        Text = "RepeaterView Demo",
                        Font = Font.SystemFontOfSize(NamedSize.Large)
                    },
                    repeater,
                    removeButton,
                    addButton
                }
            };

            viewModel.LoadData();
        }
Exemplo n.º 9
0
        public RepeaterViewPage()
        {
            var viewModel = new RepeaterViewViewModel();
            BindingContext = viewModel;

            var repeater = new RepeaterView<Thing>
            {
                Spacing = 10,
                ItemsSource = viewModel.Things,
                ItemTemplate = new DataTemplate(() =>
                {
                    var nameLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Medium) };
                    nameLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsNamePropertyName);

                    var descriptionLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Small) };
                    descriptionLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsDescriptionPropertyName);

                    ViewCell cell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Spacing = 0,
                            Children =
                            {
                                nameLabel,
                                descriptionLabel
                            }
                        }
                    };

                    return cell;
                })
            };

            var removeButton = new Button
            {
                Text = "Remove 1st Item",      
                HorizontalOptions = LayoutOptions.Start
            };

            removeButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.RemoveFirstItemCommandName);

            var addButton = new Button
            {
                Text = "Add New Item",
                HorizontalOptions = LayoutOptions.Start
            };

            addButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.AddItemCommandName);

            Content = new StackLayout
            {
                Padding = 20,
                Spacing = 5,
                Children = 
                {
                    new Label 
                    { 
                        Text = "RepeaterView Demo", 
                        Font = Font.SystemFontOfSize(NamedSize.Large)
                    },
                    repeater,
                    removeButton,
                    addButton
                }
            };

            viewModel.LoadData();
        }