DataGrid ColumnWidth issue

Dec 31, 2008 at 8:39 PM
I have several datagrids in my application... most of them are working fine, but I have a problem with one of them.  I have the columnwidth property set to '*', but it is not properly dividing the widths.  (it works fine in all my datagrids except this one).  It looks like each column is getting maybe an extra 10.0 in width than it should.

Here is the xaml for the grid...

<Engine:XDataGrid x:Name="grid" CellStyle="{DynamicResource CellStyle}" GridLinesVisibility="None" AutoGenerateColumns="False" ItemsSource="{Binding Path=ParentField.Value, ElementName=userControl, Mode=TwoWay}" CanUserAddRows="True" ColumnHeaderStyle="{DynamicResource XDataGridColumnHeaderFieldStyle}" RowStyle="{DynamicResource XDataGridRowFieldStyle}" Style="{DynamicResource XDataGridFieldStyle}" HorizontalScrollBarVisibility="Hidden" HeadersVisibility="Column" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

                <Engine:XDataGrid.Columns>

                    <dg:DataGridTemplateColumn x:Name="columnsComboBoxColumn" Header="{x:Static MyResources:Resources.DatabaseColumn}" Width="*"  >
                        <dg:DataGridTemplateColumn.CellTemplate >
                            <DataTemplate >
                                <TextBlock Text="{Binding ColumnName}" Margin="3,0,0,0" VerticalAlignment="Center"/>
                            </DataTemplate>
                        </dg:DataGridTemplateColumn.CellTemplate>
                        <dg:DataGridTemplateColumn.CellEditingTemplate >
                            <DataTemplate >
                                <ComboBox ItemsSource="{Binding Path=Columns, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Engine:XReferencedFieldsBox}}, Mode=OneWay}" SelectedValue="{Binding Path=ColumnName, Mode=TwoWay}"   LostFocus="MeLostFocus"/><!--SelectedValue="{Binding Path=TableName, Mode=TwoWay}" SelectedValuePath="ISO" DisplayMemberPath="Identifier"-->
                            </DataTemplate>
                        </dg:DataGridTemplateColumn.CellEditingTemplate>
                    </dg:DataGridTemplateColumn>


                   <dg:DataGridTemplateColumn Header="{x:Static MyResources:Resources.Value}" Width="*">
                        <dg:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Padding="5,0,5,0" Text="{Binding Value}"/>
                            </DataTemplate>
                        </dg:DataGridTemplateColumn.CellTemplate>
                        <dg:DataGridTemplateColumn.CellEditingTemplate>
                            <DataTemplate>
                                <Grid x:Name="textboxButtonGrid">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="{Binding Path=ActualHeight, ElementName=textboxButtonGrid, Mode=OneWay}"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBox Grid.Column="0" Text="{Binding Value, Mode=TwoWay}"  PreviewKeyDown="TextBox_PreviewKeyDown" LostFocus="MeLostFocus"/>
                                    <Engine:XButton Grid.Column="1" Click="XButton_Click" Content="..." Style="{DynamicResource XButtonStyle}"/>
                                </Grid>
                            </DataTemplate>
                        </dg:DataGridTemplateColumn.CellEditingTemplate>

                    </dg:DataGridTemplateColumn>

                </Engine:XDataGrid.Columns>
            </Engine:XDataGrid>


Thanks in advance for the help...