HiveBrain v1.2.0
Get Started
← Back to all entries
patterncsharpModerate

Is nesting grids a good idea?

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
nestingideagridsgood

Problem

I find myself nesting a lot of grids inside grids in WPF. I just found myself 3 Grids deep, and stopped to think: "Should I be doing this?" Is there some kind of performance cost? Is it unmaintainable? (Kind of like heavily nested ifs maybe.)

I guess the alternative is to have one grid, and use a whole lot of column spans.

(You may ignore the use of Events, I am aware commands are prob a better idea)





































Solution

It's better to use nested grids that are easy to read, than complex spanning. I try to avoid spanning in most scenarios, unless it's just 1 simple span. But when in doubt, nest the grids, because that way future layout changes won't break everything where as spanning is directly tied to the number of columns you have.

A great example of this is headers and footers, you wouldn't want them to not fill the width of an app,

Context

StackExchange Code Review Q#12091, answer score: 19

Revisions (0)

No revisions yet.