Understanding Layouts and LayoutInputs

March 4, 2008 at 11:38 am 1 comment

Creating a layout can be somewhat cumbersome at first, in this post I will try to explain how to create a common layout.

My experience is that FormLayouts and AnchorLayouts are the most useful of all types of layouts, the two act almost similar and the only difference is that the former always fills to the size of its parent, the latter sizes to the combined size of its children.
By applying a FormLayout to the outermost Panel or ColorFill in a UI, as the SDK recommends, you can take full control of positioning viewitems on the screen as children of this Panel or ColorFill.
To align these children, FormLayoutInputs should be applied to them, for example one like this:

<FormLayoutInput Top=”Parent,0,50″ Right=”Parent,1,-30″/>

This is what it actually means:

The right border of the viewitem is anchored at 100% of width of the parent, minus 30px. The first parameter of the Right-attribute is the reference for defining the anchor, the second parameter is the offset that should be applied as a fraction of the width of the parent, the third is an additional offset in pixels.

The same logic can be applied to the Top-attribute, except that the offsets relate to the height and the vertical position, so the top of the viewitem is anchored 50px below the top of the parent.

The reference can either be the Parent viewitem, the name of a sibling viewitem or Focus. The Focus-reference anchors a viewitem to whichever sibling that has input-focus.

Good luck!

Entry filed under: MCML, Windows Media Center. Tags: .

Welcome to my blog! How to attach the debugger at application startup

1 Comment Add your own

  • 1. Ian Dixon's Blog : New Media Center Developer Blog  |  March 10, 2008 at 12:31 pm

    [...] I was very pleased to see a new Media Center Development Blog, the blog which covers topics such as Understanding Layouts and LayoutInputs and How to attach the debugger at application startup has been started Johan van Ruth a regular [...]

    Reply

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Posts

Categories

Feeds


Follow

Get every new post delivered to your Inbox.