Resize an object automatically at runtime
When you resize an object, you might not get the result you expect if the properties under Layout in the Properties panel are not set correctly. The properties that affect the size of an object are the width, height, alignment, and margin properties. For example, if you want an object to resize automatically at runtime when the size of the application window changes, you must set the Width and Height to Auto, select the HorizontalAlignment and VerticalAlignment that you want, and then adjust the size by using the Margin properties.
To resize an object automatically at runtime
On the artboard or in the ObjectsandTimeline panel, click the object that you want to resize to select it.
Under Layout in the Properties panel, click Set to Auto . Alternatively, click Advanced options next to the Width and Height property, and then click Auto.
Note
When you set the width and height of an object to Auto, your object might reduce in size until you adjust the margin properties to pull the sides of the object toward the edges of the containing object.
The next properties that are listed under Width and Height depend on the type of layout panel that contains your object. For example, if the parent object is a Grid layout panel, you will see Row, RowSpan, Column, and ColumnSpan properties. If the parent object is a Canvas, you will see Left and Top properties. You can set these properties to determine the position of your object in the layout panel.
Note
If the parent object is a StackPanel layout panel, the child objects will not have extra properties under Width and Height because the layout is determined by the Orientation property of the StackPanel, and all child objects are stacked in the order provided in the Objects and Timeline panel.
Still under Layout in the Properties panel, set the HorizontalAlignment and VerticalAlignment properties by clicking one of the following buttons:
Left
Center
Right
Stretch
Finally, set the Margin properties to determine how far from the sides of the containing object to display your object.
Note
These margin values will stay static. In other words, if the size of your application window is reduced far enough, your object will disappear completely. You can prevent your object from disappearing by setting the minimum width and minimum height properties. Under Layout in the Properties panel, click Show advanced properties , and then enter values in the MinWidth and MinHeight properties.