silverlightsilverlight-4.0datagrid

How to set the width of a column in a datagrid to *


I have got datagrid with few columns, and I want to have one of them always fill empty space of this datagrid. Hwo can I change this code to have this result? Unfortunately this is not my code

<data:DataGrid
                            x:Name="grdArchive" 
                            Grid.Row="0" 
                            Visibility="Visible"  
                            Style="{StaticResource DGrid}"
                            ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
                            RowStyle="{StaticResource DataGridRowStyle}"
                            GridLinesVisibility="Horizontal"
                            SelectionMode="Single"
                            AutoGenerateColumns="False" 
                            Background="#FFFFFF"
                            VerticalAlignment="Stretch" 
                            HorizontalAlignment="Stretch"
                            IsReadOnly="True"
                            CanUserResizeColumns="False"
                            LoadingRow="grdMessages_LoadingRow">
            <data:DataGrid.Columns>


                <!-- COLUMN: ESCALATE TYPE ID -->
                <data:DataGridTemplateColumn CanUserSort="True"
                                             SortMemberPath="EscalateTypeId">
                    <data:DataGridTemplateColumn.CellTemplate>

                        <DataTemplate>
                            <TextBlock Text="{Binding EscalateTypeId, Converter={StaticResource cnvMessagingStrings}, ConverterParameter=2}" 
                                       VerticalAlignment="Center"
                                       Margin="5,0,5,0"/>
                        </DataTemplate>

                    </data:DataGridTemplateColumn.CellTemplate>

                </data:DataGridTemplateColumn>

Solution

  • Set Width="*" for one of your DataGridTemplateColumn.

    <data:DataGridTemplateColumn CanUserSort="True"
                                    SortMemberPath="EscalateTypeId"
                                    Width="*">