smeacham

Untitled

May 17th, 2016
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 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 AbsoluteLayoutDemoVS
  10. {
  11.     class MyContentPage : ContentPage
  12.     {
  13.         public MyContentPage()
  14.         {
  15.             AbsoluteLayout absoluteLayout = new AbsoluteLayout
  16.             {
  17.                 VerticalOptions = LayoutOptions.FillAndExpand
  18.             };
  19.  
  20.             Label firstLabel = new Label
  21.             {
  22.                 Text = "FirstLabel"
  23.             };
  24.  
  25.             /* Shorthand method:
  26.             absoluteLayout.Children.Add(
  27.                 firstLabel,
  28.                 new Rectangle(
  29.                     0, 0,
  30.                     AbsoluteLayout.AutoSize,
  31.                     AbsoluteLayout.AutoSize),
  32.                 AbsoluteLayoutFlags.PositionProportional);
  33.             */
  34.  
  35.             absoluteLayout.Children.Add(firstLabel);
  36.             AbsoluteLayout.SetLayoutFlags(firstLabel,
  37.                 AbsoluteLayoutFlags.PositionProportional);
  38.             AbsoluteLayout.SetLayoutBounds(firstLabel,
  39.                 new Rectangle(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
  40.  
  41.             this.Content = absoluteLayout;
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment