Advertisement
StoneHaos

Untitled

Feb 21st, 2022
699
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public partial class MainWindow : Window {
  2.         public MainWindow() {
  3.             InitializeComponent();
  4.             GO();
  5.         }
  6.  
  7.         public void GO() {
  8.             myEntities a = new myEntities();
  9.             var b = a.Person.ToList();
  10.  
  11.             for (int i = 0; i < b.Count; ++ i) {
  12.                 RowDefinition row = new RowDefinition();
  13.                 Data.RowDefinitions.Add(row);
  14.  
  15.                 TextBlock id = new TextBlock();
  16.                 id.HorizontalAlignment = HorizontalAlignment.Center;
  17.                 id.VerticalAlignment = VerticalAlignment.Center;
  18.                 id.Text = b[i].id.ToString();
  19.                 Data.Children.Add(id);
  20.                 Grid.SetRow(id, i);
  21.                 Grid.SetColumn(id, 0);
  22.  
  23.                 TextBlock name = new TextBlock();
  24.                 name.HorizontalAlignment = HorizontalAlignment.Center;
  25.                 name.VerticalAlignment = VerticalAlignment.Center;
  26.                 name.Text = b[i].name;
  27.                 Data.Children.Add(name);
  28.                 Grid.SetRow(name, i);
  29.                 Grid.SetColumn(name, 1);
  30.  
  31.                 TextBlock lastname = new TextBlock();
  32.                 lastname.HorizontalAlignment = HorizontalAlignment.Center;
  33.                 lastname.VerticalAlignment = VerticalAlignment.Center;
  34.                 lastname.Text = b[i].lastname;
  35.                 Data.Children.Add(lastname);
  36.                 Grid.SetRow(lastname, i);
  37.                 Grid.SetColumn(lastname, 2);
  38.  
  39.                 TextBlock surname = new TextBlock();
  40.                 surname.HorizontalAlignment = HorizontalAlignment.Center;
  41.                 surname.VerticalAlignment = VerticalAlignment.Center;
  42.                 surname.Text = b[i].surname;
  43.                 Data.Children.Add(surname);
  44.                 Grid.SetRow(surname, i);
  45.                 Grid.SetColumn(surname, 3);
  46.  
  47.                 TextBlock age = new TextBlock();
  48.                 age.HorizontalAlignment = HorizontalAlignment.Center;
  49.                 age.VerticalAlignment = VerticalAlignment.Center;
  50.                 age.Text = b[i].age.ToString();
  51.                 Data.Children.Add(age);
  52.                 Grid.SetRow(age, i);
  53.                 Grid.SetColumn(age, 4);
  54.             }
  55.         }
  56.     }
Advertisement
RAW Paste Data Copied
Advertisement