Advertisement
Guest User

UWP LabelGrid

a guest
Jan 16th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. public void ArrangeWidgets(IEnumerable<UIElement> uiWidgets)
  2. {
  3.     int curRow = -1;
  4.     int curCol = 1;
  5.  
  6.     RowDefinitions.Clear();
  7.     Children.Clear();
  8.  
  9.     if (uiWidgets != null)
  10.         foreach (var curChild in uiWidgets)
  11.         {
  12.             Children.Add(curChild);
  13.  
  14.             if (curCol == 0)
  15.             {
  16.                 curCol = 1;
  17.             }
  18.             else
  19.             {
  20.                 curCol = 0;
  21.                 curRow++;
  22.                 RowDefinitions.Add(new RowDefinition()
  23.                 {
  24.                     Height = new GridLength(1, GridUnitType.Auto)
  25.                 });
  26.             }
  27.  
  28.             Grid.SetRow((FrameworkElement)curChild, curRow);
  29.             Grid.SetColumn((FrameworkElement)curChild, curCol);
  30.         }
  31.  
  32.     RowDefinitions.Add(new RowDefinition()
  33.     {
  34.         Height = new GridLength(1, GridUnitType.Star)
  35.     });
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement