public OldMainPage() { Grid layout = new Grid { Padding = new Thickness(5, 0), RowSpacing = 1, ColumnSpacing = 1, BackgroundColor = Color.Black, }; // Setup the grid 4x6 layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }); layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this.resultText = new Label { Font = Font.SystemFontOfSize(48, FontAttributes.Bold), BackgroundColor = Color.Black, TextColor = Color.White, XAlign = TextAlignment.End, YAlign = TextAlignment.Center, LineBreakMode = LineBreakMode.NoWrap, }; Grid.SetColumnSpan(this.resultText, 4); layout.Children.Add(this.resultText); // Create the numbers. layout.Children.Add(CreateNumberButton("7", 1, 0)); layout.Children.Add(CreateNumberButton("8", 1, 1)); layout.Children.Add(CreateNumberButton("9", 1, 2)); layout.Children.Add(CreateNumberButton("4", 2, 0)); layout.Children.Add(CreateNumberButton("5", 2, 1)); layout.Children.Add(CreateNumberButton("6", 2, 2)); layout.Children.Add(CreateNumberButton("1", 3, 0)); layout.Children.Add(CreateNumberButton("2", 3, 1)); layout.Children.Add(CreateNumberButton("3", 3, 2)); Button zero = CreateNumberButton("0", 4, 0); Grid.SetColumnSpan(zero, 3); layout.Children.Add(zero); // Create the operators layout.Children.Add(CreateOperatorButton("/", 1)); layout.Children.Add(CreateOperatorButton("X", 2)); layout.Children.Add(CreateOperatorButton("-", 3)); layout.Children.Add(CreateOperatorButton("+", 4)); // Create the clear button. Button clear = new Button() { Text = "C", BackgroundColor = Color.FromRgb(0x80, 0x80, 0x80), TextColor = Color.White, Font = Font.SystemFontOfSize(36), BorderRadius = 0, }; Grid.SetRow(clear, 5); clear.Clicked += OnClear; layout.Children.Add(clear); // And the equals. Button equals = new Button() { Text = "=", BackgroundColor = Color.FromHex("#FFA500"), TextColor = Color.White, Font = Font.SystemFontOfSize(36), BorderRadius = 0, }; Grid.SetRow(equals, 5); Grid.SetColumn(equals, 1); Grid.SetColumnSpan(equals, 3); equals.Clicked += OnCalculate; layout.Children.Add(equals); OnClear(null, EventArgs.Empty); Content = layout; }