I have 2 Silverlight UserControls that need to be placed side by side in a container. Any of them is present (visible) optionally and in case one is missing I want the remaining one to take 100% width of the container. Basically there are 4 possible states: if none of the 2 controls is present the container is collapsed. The other are like
this
The furthest I got so far is using a Grid with two columns
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<userControls:LeftControl Grid.Column="0" ...></userControls:LeftControl>
<userControls:RightControl Grid.Column="1" ...></userControls:RightControl>
</Grid>
This works fine except the case the right control is missing. The left then doesn’t stretch.
I don’t think Silverlight layout system is capable of figuring this out on its own.
See if something like this gets you closer to your answer.
Markup:
Code behind: