views:

29

answers:

1

Hello I want a silverlight grid layout panel.
The width should be 100%.
There should be 2 columns that both take 50%.
In the columns there should be buttons that take 100% of the column cell..


Somehow I mess it up all the time and cannot find a way to do this.
Gridpanel is not a must... Stackpanel or whatever is fine too..
One more thing.. the grid is contained in a stackpanel
If nothing works.. code is fine too..

-------Stackpanel--------
|---griddpanel-100%-----|
||50%       |50%       ||
||Button100%|Button100%||
|-----------------------|
-------------------------

Thanks for any help...

+1  A: 

This should do it it:

<StackPanel>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="50*" />
            <ColumnDefinition Width="50*" />
        </Grid.ColumnDefinitions>
        <Button Grid.Column="0">B1</Button>
        <Button Grid.Column="1">B2</Button>                
    </Grid>
</StackPanel>
Henk Holterman
Note the 50* and 50* are relative values (relative only to other star-sized columns), you you can just use "*" and "*" instead. Also defining a Grid.Column or Grid.Row of 0 is redundant as that is the default.
Enough already
@HiTech: both points are deliberate. This way the answer is a more general template.
Henk Holterman
Thank you very much..I must say, in the end, the solution is rather elegant..
Julian de Wit
@Henk: that's why I said "Note" for the asker and not @ you :)
Enough already