A lot of controls in GUI will fill any available space they are given. In the pg you posted, the stack panel had a default width so it filled the entire region. In that case, it doesn’t really matter if you anchor it.
There are a lot of ways to solve this one. Here is one simple approach.
This example sets the panel to a fixed width, then lets the buttons fill it.
- Added
panel.width = "200px"
you could also use a percent here - Removed
button.width = 0.2;
andbutton2.width = 0.2;
For your second question, you may want to consider a grid instead of a stack panel. You could position the grid just like above, but them fill it with columns and rows as needed