Select to view content in your preferred language

Silverlight Question

675
1
09-13-2010 05:31 AM
CraigPerreault
Deactivated User
I have this XAML code:

            <ListBox x:Name="SearchResultsList"  Height="260" Width="394" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid x:Name="grdSearch">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="Col0" Width="170"></ColumnDefinition>
                                <ColumnDefinition x:Name="Col1" Width="70"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Name}" Margin="6,1,0,0" Grid.Column="0"/>
                            <TextBlock Text="{Binding Type}" Margin="6,1,0,0" Grid.Column="1"/>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>


I can change the size of the List Box like this
this.SearchResultsList.Width = 400

Can anyone show me how to change the width of Col1.  This does not work?
this.Col1 = new GridLength(200, GridUnitType.Pixel);
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
Instead of setting width on each of your column definition, use "Auto", so each column can adjust its width depending on the size of its content. Also, set the HorizontalContentAlignment of ListBox to "Stretch", so that the grid would stretch as the ListBox increase its width.
0 Kudos