Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workaround for Grid.SharedSizeGroup in Silverlight

There is no Grid.SharedSizeGroup in Silverlight 4. What is your workaround for this issue?

For example: I have a DataTemplate for ListBox.ItemTemplate consisting of a grid with two columns and I'd like to have the same width for both columns and the first column needs to have auto width.

like image 591
Lukas Cenovsky Avatar asked Nov 15 '10 20:11

Lukas Cenovsky


3 Answers

Vote for this feature here:

http://dotnet.uservoice.com/forums/4325-silverlight-feature-suggestions/suggestions/1454947-sharedsizegroup

and also here:

http://connectppe.microsoft.com/VisualStudio/feedback/details/518461/sharedsizegroup-should-be-available-in-silverlight

like image 188
Jonas Kello Avatar answered Sep 21 '22 15:09

Jonas Kello


SharedSize Grid with Silverlight - haven't tested it but looks usable.

like image 31
Lukas Cenovsky Avatar answered Sep 24 '22 15:09

Lukas Cenovsky


Shared sizing is best implemented using element property bindings in Silverlight. Just make all your shared sized elements bind to the width/height of another.

EDIT: I put a quick example of what I mean together. I'm not sure what you mean by using star sizing when you said in the question you want auto sizing -

<Grid Height="400"
      Width="600"
      Background="Gray">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Button x:Name="parent"
            Content="CHANGE ME TO ADJUST THE COLUMN SIZE"
            Grid.Column="0"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"
            Background="Red" />
    <Button Width="{Binding ActualWidth, ElementName=parent}"
            Grid.Column="1"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"
            Background="Blue" />
    <Button Width="{Binding ActualWidth, ElementName=parent}"
            Grid.Column="2"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"
            Background="Yellow" />
</Grid>

HTH

like image 45
EightyOne Unite Avatar answered Sep 24 '22 15:09

EightyOne Unite