Export (0) Print
Expand All

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 Objects and Timeline panel, click the object that you want to resize to select it.

  2. Under Layout in the Properties panel, click Set to Auto Cc295141.aa9ec064-22f8-4b62-9eed-3f4772362d22(en-us,Expression.40).png. Alternatively, click Advanced options Cc295141.12e06962-5d8a-480d-a837-e06b84c545bb(en-us,Expression.40).png next to the Width and Height property, and then click Auto.

    NoteNote

    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.

    NoteNote

    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 Cc295141.1e3c2891-633d-4162-a3bd-d5ac53046b56(en-us,Expression.40).png

    • Center Cc295141.02978741-8e12-476d-afa7-165b613ea515(en-us,Expression.40).png

    • Right Cc295141.c0d22c24-ad68-4355-b8f2-d6a373deaf8e(en-us,Expression.40).png

    • Stretch Cc295141.90aa9534-0480-4a7f-b992-1af23c71ea9c(en-us,Expression.40).png

  5. Finally, set the Margin properties to determine how far from the sides of the containing object to display your object.

    NoteNote

    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 Cc295141.de239c9d-42ce-4f5e-83b9-5f9924c0431f(en-us,Expression.40).png, and then enter values in the MinWidth and MinHeight properties.

See also

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.
Show:
© 2015 Microsoft