The other day, I had to show different datatemplates depending on a specific property value. (The datatemplateSelector is your friend!)
I used different foreground colors to visualize the states; however, the layout design was the same for each datatemplate.
I was using a Grid, and wanted to share the columnWidth’s and RowHeight’s.
My first solution was specifying a double constant in xaml. Unfortunately, this doesn’t work out of the box. You would need to have a DoubleToGridLengthConverter.
Then, after some searching I found this Grid Size Sharing sample!
Basically, you have to define the attached Grid.IsSharedSizeScope on the container element to set the scope of the shared sizes.
Then when you set the SharedSizeGroup on a row/column definition (together with the width/height of course), other definitions with the same name will automagically adjust as well.
nice!