コード例 #1
0
        public ImageCellListPage()
        {
            Title = "ImageCell List Gallery - Legacy";

            if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
            {
                Padding = new Thickness(0, 0, 0, 60);
            }

            var dataTemplate = new DataTemplate(typeof(ImageCell));
            var stringToImageSourceConverter = new GenericValueConverter(
                obj => new FileImageSource
            {
                File = (string)obj
            }
                );

            dataTemplate.SetBinding(TextCell.TextProperty, new Binding("Text"));
            dataTemplate.SetBinding(TextCell.TextColorProperty, new Binding("TextColor"));
            dataTemplate.SetBinding(TextCell.DetailProperty, new Binding("Detail"));
            dataTemplate.SetBinding(TextCell.DetailColorProperty, new Binding("DetailColor"));
            dataTemplate.SetBinding(ImageCell.ImageSourceProperty, new Binding("Image", converter: stringToImageSourceConverter));

            Random rand = new Random(250);

            var albums = new[] {
                "crimsonsmall.jpg",
                "oasissmall.jpg",
                "cover1small.jpg"
            };

            var label = new Label {
                Text = "I have not been selected"
            };

            var listView = new ListView
            {
                AutomationId = CellTypeList.CellTestContainerId,
                ItemsSource  = Enumerable.Range(0, 100).Select(i => new ImageCellTest
                {
                    Text        = "Text " + i,
                    TextColor   = i % 2 == 0 ? Color.Red : Color.Blue,
                    Detail      = "Detail " + i,
                    DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
                    Image       = albums[rand.Next(0, 3)]
                }),
                ItemTemplate = dataTemplate
            };

            listView.ItemSelected += (sender, args) => label.Text = "I was selected";

            Content = new StackLayout {
                Children = { label, listView }
            };
        }
コード例 #2
0
        public UrlImageCellListPage()
        {
            if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
            {
                Padding = new Thickness(0, 0, 0, 60);
            }

            var dataTemplate = new DataTemplate(typeof(ImageCell));
            var stringToImageSourceConverter = new GenericValueConverter(
                obj => new UriImageSource()
            {
                Uri = new Uri((string)obj)
            });

            dataTemplate.SetBinding(TextCell.TextProperty, new Binding("Text"));
            dataTemplate.SetBinding(TextCell.TextColorProperty, new Binding("TextColor"));
            dataTemplate.SetBinding(TextCell.DetailProperty, new Binding("Detail"));
            dataTemplate.SetBinding(TextCell.DetailColorProperty, new Binding("DetailColor"));
            dataTemplate.SetBinding(ImageCell.ImageSourceProperty,
                                    new Binding("Image", converter: stringToImageSourceConverter));

            var albums = new List <string>();

            for (int i = 0; i < 30; i++)
            {
                albums.Add(string.Format("https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/Xamarin.Forms.Controls/coffee.png?ticks={0}", i));
            }


            var random = new Random();
            var label  = new Label {
                Text = "I have not been selected"
            };

            var listView = new ListView
            {
                AutomationId = "ImageUrlCellListView",
                ItemsSource  = Enumerable.Range(0, 300).Select(i => new ImageCellTest
                {
                    Text        = "Text " + i,
                    TextColor   = i % 2 == 0 ? Color.Red : Color.Blue,
                    Detail      = "Detail " + i,
                    DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
                    Image       = albums[random.Next(0, albums.Count - 1)]
                }),
                ItemTemplate = dataTemplate
            };

            listView.ItemSelected += (sender, args) => label.Text = "I was selected";

            Content = new StackLayout {
                Children = { label, listView }
            };
        }
コード例 #3
0
		public ImageCellListPage ()
		{
			Title = "ImageCell List Gallery - Legacy";

			Device.OnPlatform (iOS: () => {
				if (Device.Idiom == TargetIdiom.Tablet) {
					Padding = new Thickness (0, 0, 0, 60);
				}
			});

			var dataTemplate = new DataTemplate (typeof (ImageCell));
			var stringToImageSourceConverter = new GenericValueConverter (
				obj => new FileImageSource {
					File = (string) obj
				}
				);
	
			dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text"));
			dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor"));
			dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail"));
			dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor"));
			dataTemplate.SetBinding (ImageCell.ImageSourceProperty, new Binding ("Image", converter: stringToImageSourceConverter));

			Random rand = new Random(250);

			var albums = new [] {
				"crimsonsmall.jpg",
				"oasissmall.jpg",
				"cover1small.jpg"
			};

			var label = new Label { Text = "I have not been selected" };

			var listView = new ListView {
				AutomationId = "ImageCellListView",
				ItemsSource = Enumerable.Range (0, 100).Select (i => new ImageCellTest {
					Text = "Text " + i,
					TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Detail = "Detail " + i,
					DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Image = albums[rand.Next(0,3)]
				}),
				ItemTemplate = dataTemplate
			};

			listView.ItemSelected += (sender, args) => label.Text = "I was selected";

			Content = new StackLayout { Children = { label, listView } };

		}
コード例 #4
0
		public ExpenseListViewCell ()
		{
			var expenseNameLabel = new Label ();
			expenseNameLabel.SetBinding (Label.TextProperty, "Name");

			var expenseAmountLabel = new Label ();
			var expenseAmountToStringConverter = new GenericValueConverter (obj => string.Format ("{0:C}", ((decimal)obj)));
			expenseAmountLabel.SetBinding (Label.TextProperty, new Binding ("Amount", converter: expenseAmountToStringConverter));

			var layout = new StackLayout ();

			layout.Children.Add (expenseNameLabel);
			layout.Children.Add (expenseAmountLabel);

			View = layout;
		}
コード例 #5
0
		public UrlImageCellListPage()
		{
			Device.OnPlatform (iOS: () => {
				if (Device.Idiom == TargetIdiom.Tablet) {
					Padding = new Thickness (0, 0, 0, 60);
				}
			});

			var dataTemplate = new DataTemplate (typeof (ImageCell));
			var stringToImageSourceConverter = new GenericValueConverter (
				obj => new UriImageSource() {
					Uri = new Uri ((string) obj)
				});

			dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text"));
			dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor"));
			dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail"));
			dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor"));
			dataTemplate.SetBinding (ImageCell.ImageSourceProperty,
				new Binding ("Image", converter: stringToImageSourceConverter));

			var albums = new List<string> ();
			for (int i = 0; i < 30; i++) {
				albums.Add (string.Format ("http://cdn.instructables.com/FCP/9TOJ/GCJ0ZQV5/FCP9TOJGCJ0ZQV5.MEDIUM.jpg?ticks={0}",i ));
			}


			var random = new Random();
			var label = new Label { Text = "I have not been selected" };

			var listView = new ListView {
				AutomationId = "ImageUrlCellListView",
				ItemsSource = Enumerable.Range (0, 300).Select (i => new ImageCellTest {
					Text = "Text " + i,
					TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Detail = "Detail " + i,
					DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Image = albums [random.Next (0, albums.Count - 1)]
				}),
				ItemTemplate = dataTemplate
			};

			listView.ItemSelected += (sender, args) => label.Text = "I was selected";

			Content = new StackLayout { Children = { label, listView } };

		}
コード例 #6
0
        public ExpenseListViewCell()
        {
            var expenseNameLabel = new Label();

            expenseNameLabel.SetBinding(Label.TextProperty, "Name");

            var expenseAmountLabel             = new Label();
            var expenseAmountToStringConverter = new GenericValueConverter(obj => string.Format("{0:C}", ((decimal)obj)));

            expenseAmountLabel.SetBinding(Label.TextProperty, new Binding("Amount", converter: expenseAmountToStringConverter));

            var layout = new StackLayout();

            layout.Children.Add(expenseNameLabel);
            layout.Children.Add(expenseAmountLabel);

            View = layout;
        }
コード例 #7
0
        public UrlImageViewCellListPage()
        {
            if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
            {
                Padding = new Thickness(0, 0, 0, 60);
            }

            var stringToImageSourceConverter = new GenericValueConverter(
                obj => new UriImageSource()
            {
                Uri = new Uri((string)obj)
            });

            var dataTemplate = new DataTemplate(() => {
                var cell = new ViewCell();

                var image = new Image();
                image.SetBinding(Image.SourceProperty, new Binding("Image", converter: stringToImageSourceConverter));
                image.WidthRequest  = 160;
                image.HeightRequest = 160;

                var text = new Label();
                text.SetBinding(Label.TextProperty, new Binding("Text"));
                text.SetBinding(Label.TextColorProperty, new Binding("TextColor"));

                cell.View = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        image,
                        text
                    }
                };

                return(cell);
            });

            var albums = new string[25];

            for (int n = 0; n < albums.Length; n++)
            {
                albums[n] =
                    string.Format(
                        "https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/Xamarin.Forms.Controls/coffee.png?ticks={0}", n);
            }

            var label = new Label {
                Text = "I have not been selected"
            };

            var listView = new ListView {
                AutomationId = CellTypeList.CellTestContainerId,
                ItemsSource  = Enumerable.Range(0, albums.Length).Select(i => new UrlImageViewCellListPageModel {
                    Text      = "Text " + i,
                    TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
                    Image     = albums[i]
                }),
                ItemTemplate = dataTemplate
            };

            listView.ItemSelected += (sender, args) => label.Text = "I was selected";

            Content = new StackLayout {
                Children = { label, listView }
            };
        }
コード例 #8
0
        public UrlImageViewCellListPage()
        {
            if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
            {
                Padding = new Thickness(0, 0, 0, 60);
            }

            var stringToImageSourceConverter = new GenericValueConverter(
                obj => new UriImageSource()
            {
                Uri = new Uri((string)obj)
            });

            var dataTemplate = new DataTemplate(() => {
                var cell = new ViewCell();

                var image = new Image();
                image.SetBinding(Image.SourceProperty, new Binding("Image", converter: stringToImageSourceConverter));
                image.WidthRequest  = 160;
                image.HeightRequest = 160;

                var text = new Label();
                text.SetBinding(Label.TextProperty, new Binding("Text"));
                text.SetBinding(Label.TextColorProperty, new Binding("TextColor"));

                cell.View = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        image,
                        text
                    }
                };

                return(cell);
            });

            var albums = new[] {
                "https://evolve.xamarin.com/images/sessions/joseph-mayo-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jon-skeet-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/rachel-reese-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/mike-james-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/daniel-cazzulino-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/michael-hutchinson-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/laurent-bugnion-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/craig-dunn-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/charles-petzold-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jason-smith-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/frank-krueger-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/james-clancey-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/daniel-plaisted-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jesse-liberty-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/miguel-de-icaza-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/rene-ruppert-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/brent-schooley-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/adrian-stevens-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/rodrigo-kumpera-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/alex-corrado-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jonathan-pryor-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/michael-stonis-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jeremie-laval-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/james-montemagno-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/brett-duncavage-icon.jpg"
            };

            var label = new Label {
                Text = "I have not been selected"
            };

            var listView = new ListView {
                ItemsSource = Enumerable.Range(0, albums.Length).Select(i => new {
                    Text        = "Text " + i,
                    TextColor   = i % 2 == 0 ? Color.Red : Color.Blue,
                    Detail      = "Detail " + i,
                    DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
                    Image       = albums[i]
                }),
                ItemTemplate = dataTemplate
            };

            listView.ItemSelected += (sender, args) => label.Text = "I was selected";

            Content = new StackLayout {
                Children = { label, listView }
            };
        }