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

  1. On the artboard or in the ObjectsandTimeline panel, click the object that you want to resize to select it.

  2. Under Layout in the Properties panel, click Set to Auto aa9ec064-22f8-4b62-9eed-3f4772362d22. Alternatively, click Advanced options 12e06962-5d8a-480d-a837-e06b84c545bb 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.

  3. 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.

  4. Still under Layout in the Properties panel, set the HorizontalAlignment and VerticalAlignment properties by clicking one of the following buttons:

    • Left 1e3c2891-633d-4162-a3bd-d5ac53046b56

    • Center 02978741-8e12-476d-afa7-165b613ea515

    • Right c0d22c24-ad68-4355-b8f2-d6a373deaf8e

    • Stretch 90aa9534-0480-4a7f-b992-1af23c71ea9c

  5. 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 de239c9d-42ce-4f5e-83b9-5f9924c0431f, and then enter values in the MinWidth and MinHeight properties.

See Also

Tasks

Resize or scale an object