#394 – Specify Canvas Child Element Position Using Two Properties

When positioning child elements in a Canvas element, you can position the child element by specifying one or more of the properties: Left, Top, Right, Bottom.

In practice, the values of only two of these properties are ever used.  If Left and Right are specified, Right is ignored.  If Top and Bottom are specified, Bottom is ignored.

If neither Left nor Right are specified, a value of 0 is used for Left.  If neither Top nor Bottom are specified, a value of 0 is used for Top.

It’s a good idea, then, to always specify exactly two of these four properties, in any of the following combinations:

  • Left / Top
  • Left / Bottom
  • Right / Top
  • Right / Bottom

By always specifying exactly two properties, none are ignored and you never implicitly use a value of 0, but make the positioning clear by explicitly specifying both values that are to be used.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: