Advertisement
smeacham

ListItemCell.cs

May 24th, 2016
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. using Xamarin.Forms;
  8.  
  9. namespace ListViewDemoVS
  10. {
  11.     class ListItemCell : ViewCell
  12.     {
  13.         public ListItemCell()
  14.         {
  15.             Label titleLabel = new Label
  16.             {
  17.                 HorizontalOptions = LayoutOptions.FillAndExpand,
  18.                 FontSize = 25,
  19.                 FontAttributes = Xamarin.Forms.FontAttributes.Bold,
  20.                 TextColor = Color.White
  21.             };
  22.             titleLabel.SetBinding(Label.TextProperty, "Title");
  23.  
  24.             Label descLabel = new Label
  25.             {
  26.                 HorizontalOptions = LayoutOptions.FillAndExpand,
  27.                 FontSize = 12,
  28.                 TextColor = Color.White
  29.             };
  30.             descLabel.SetBinding(Label.TextProperty, "Description");
  31.  
  32.             Label priceLabel = new Label
  33.             {
  34.                 HorizontalOptions = LayoutOptions.End,
  35.                 FontSize = 25,
  36.                 TextColor = Color.Aqua
  37.             };
  38.             priceLabel.SetBinding(Label.TextProperty, "Price");
  39.  
  40.             StackLayout viewLayoutItem = new StackLayout()
  41.             {
  42.                 HorizontalOptions = LayoutOptions.StartAndExpand,
  43.                 Orientation = StackOrientation.Vertical,
  44.                 Children = { titleLabel, descLabel }
  45.             };
  46.  
  47.             StackLayout viewLayout = new StackLayout()
  48.             {
  49.                 HorizontalOptions = LayoutOptions.StartAndExpand,
  50.                 Orientation = StackOrientation.Horizontal,
  51.                 Padding = new Thickness(25, 10, 55, 15),
  52.                 Children = { viewLayoutItem, priceLabel }
  53.             };
  54.  
  55.             View = viewLayout;
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement