public static void Main() => new Application().Run(new SetSpaceProperty()); // Entry point private SetSpaceProperty() { Title = "Set Space Property"; // Window title SizeToContent = SizeToContent.WidthAndHeight; // Automatically resize height and width relative to content ResizeMode = ResizeMode.CanMinimize; // We can only hide the window (_ button) but can't open in fullscreen int[] iSpaces = { 0, 1, 2 }; // Array of integers var grid = new Grid(); // Grid layout implementation Content = grid; // Set the Content of the window as a grid layout // Add 2 rows into grid layout with height set to auto for (var i = 0; i < 2; i++) { grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } // Add 3 columns into grid layout with width set to auto for (var i = 0; i < iSpaces.Length; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); } // Add 3 buttons into first row of grid layout for (var i = 0; i < iSpaces.Length; i++) { var btn = new SpaceButton { Text = "Set window Space to " + iSpaces[i], // Text Tag = iSpaces[i], // Tag to be able to find this button HorizontalAlignment = HorizontalAlignment.Center, // Horizontal alignment VerticalAlignment = VerticalAlignment.Center // Vertical alignment }; btn.Click += WindowPropertyOnClick; // Set the event handler to each button object grid.Children.Add(btn); // Add created button to grid Grid.SetRow(btn, 0); // Set the position in grid for this button Grid.SetColumn(btn, i); // Absolutely the same actions for the second grid row btn = new SpaceButton { Text = "Set button Space to " + iSpaces[i], Tag = iSpaces[i], HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; btn.Click += ButtonPropertyOnClick; grid.Children.Add(btn); Grid.SetRow(btn, 1); Grid.SetColumn(btn, i); } }
void ReleaseDesignerOutlets() { if (AbilitiesView != null) { AbilitiesView.Dispose(); AbilitiesView = null; } if (AttacksEditorButton != null) { AttacksEditorButton.Dispose(); AttacksEditorButton = null; } if (AttacksView != null) { AttacksView.Dispose(); AttacksView = null; } if (BurrowButton != null) { BurrowButton.Dispose(); BurrowButton = null; } if (ClimbButton != null) { ClimbButton.Dispose(); ClimbButton = null; } if (FlyButton != null) { FlyButton.Dispose(); FlyButton = null; } if (FlyQualityButton != null) { FlyQualityButton.Dispose(); FlyQualityButton = null; } if (MeleeButton != null) { MeleeButton.Dispose(); MeleeButton = null; } if (RangedButton != null) { RangedButton.Dispose(); RangedButton = null; } if (ReachButton != null) { ReachButton.Dispose(); ReachButton = null; } if (SpaceButton != null) { SpaceButton.Dispose(); SpaceButton = null; } if (SpecialAttacksButton != null) { SpecialAttacksButton.Dispose(); SpecialAttacksButton = null; } if (SpeedButton != null) { SpeedButton.Dispose(); SpeedButton = null; } if (SpeedView != null) { SpeedView.Dispose(); SpeedView = null; } if (SpellLikeAbilitiesButton != null) { SpellLikeAbilitiesButton.Dispose(); SpellLikeAbilitiesButton = null; } if (SpellsKnownButton != null) { SpellsKnownButton.Dispose(); SpellsKnownButton = null; } if (SpellsPreparedButton != null) { SpellsPreparedButton.Dispose(); SpellsPreparedButton = null; } if (SwimButton != null) { SwimButton.Dispose(); SwimButton = null; } }