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); } } }
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); }
public void ViewHasThreeChildren() { var items = GetItems(); var repeaterView = new RepeaterView { ItemsSource = items }; Assert.Equal(items.Count(), repeaterView.Children.Count); }
private RepeaterView <PrayerRequestModel> GetRepeaterView() { var repeater = new RepeaterView <PrayerRequestModel> { ItemsSource = ViewModel.PrayerRequestCollection, ItemTemplate = new DataTemplate(GetTemplate) }; return(repeater); }
private View GetRepeaterView() { var repeater = new RepeaterView <EventModel> { ItemsSource = ViewModel.Events, ItemTemplate = new DataTemplate(GetEventsTemplate) }; var scrollView = new ScrollView() { Content = repeater }; return(scrollView); }
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); }
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(); }
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(); }