Resize an element automatically at runtime
When you resize an element, 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 element are the width, height, alignment, and margin properties. For example, if you want an element 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 element automatically at runtime
On the artboard or under ObjectsandTimeline in the Interaction panel, click the element that you want to resize to select it.
Under Layout in the Properties panel, click the Set to Auto button . Alternatively, click the Advanced property options marker next to the Width and Height property, and then click Auto.
Note
When you set the width and height of an element to Auto, your element might reduce in size until you adjust the margin properties to pull the sides of the element toward the edges of the containing element.
The next properties that are listed under Width and Height depend on the type of layout panel that contains your element. For example, if the parent element is a Grid layout panel, you will see Row, RowSpan, Column, and ColumnSpan properties. If the parent element is a Canvas, you will see Left and Top properties. You can set these properties to determine the position of your element in the layout panel.
Note
If the parent element is a StackPanel layout panel, the child elements will not have extra properties under Width and Height because the layout is determined by the Orientation property of the StackPanel, and all child elements are stacked in the order provided under Objects and Timeline.
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 element to display your element.
Note
These margin values will stay static. In other words, if the size of your application window is reduced far enough, your element will disappear completely. You can prevent your element from disappearing by setting the minimum width and minimum height properties. Under Layout in the Properties panel, click the Show advanced properties button , and then enter values in the MinWidth and MinHeight properties.