aaron
aaron

Reputation: 748

WPF grid XAML layout

I am writing my UI mostly in XAML without a WYSIWYG editor.

In Grids you can do:

  <TextBox  Grid.Column="0" Grid.Row="0" ...

When creating a Grid coming from a HTML background I have been doing:

<TextBox  Grid.Column="0" Grid.Row="0">
<Label Grid.Column="1" Grid.Row="0">

<TextBox  Grid.Column="0" Grid.Row="1">
<Label Grid.Column="1" Grid.Row="1">

But ordering the XAML by columns just seems neater:

<TextBox  Grid.Column="0" Grid.Row="0">
<TextBox  Grid.Column="0" Grid.Row="1">

<Label Grid.Column="1" Grid.Row="0">
<Label Grid.Column="1" Grid.Row="1">

seems neater.

I'm just curious, how everyone else is doing it?

Upvotes: 1

Views: 2014

Answers (1)

Filip Ekberg
Filip Ekberg

Reputation: 36287

That depends on whether or not you want controls to be on top of each other, that's the only significant difference when re-ordering them like that.

In XAML Controls are ordered ( the z-index ) as you add them, meaning that if you first add <TextBox> and then <Label>, the <Label> can be on-top of the <TextBox> and not the other way around.

However in your case, it is much nicer to add them ordered by row then column then z-index.

That's the way I would do it.

Upvotes: 1

Related Questions