<Grid> <dxg:GridControl Name="gridErrorsInfo" AutoPopulateColumns="True" ShowBorder="False" ShowLoadingPanel="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AllowColumnMRUFilterList="False" AllowMRUFilterList="False" Margin="0,0,4,28" MouseDoubleClick="gridErrorsInfo_MouseDoubleClick"> <dxg:GridControl.Columns> <dxg:GridColumn Name="Num" FieldName="Num" Header="NUM" Width="100"/> <dxg:GridColumn Name="PageName" FieldName="PageName" Header="Name" Width="150"/> <dxg:GridColumn Name="Errors" FieldName="ErrorDetail" Width="Auto" Header="Megs"/> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TableView Name="ErrorViewList" AutoWidth="True" AllowMoveColumnToDropArea="False"/> </dxg:GridControl.View> </dxg:GridControl> </Grid>
<dxg:GridControl.View> <dxg:TableView Name="ErrorViewList" AutoWidth="True" AllowMoveColumnToDropArea="False" /> </dxg:GridControl.View>
上面代码里面最主要的就是上面的这两句。
<DataGrid AutoGenerateColumns="False" Height="190" HorizontalAlignment="Left" Margin="2,5,0,0" Name="dataChartSingle" VerticalAlignment="Top" Width="225" IsReadOnly="True"> <DataGrid.Columns> <DataGridTextColumn Header="VarNumber" Binding="{Binding VarName}" Width="130" CanUserSort="False" CanUserResize="True"/> <DataGridTextColumn Header="MaxVar" Binding="{Binding VarMax}" Width="48" CanUserSort="False" CanUserResize="True" /> <DataGridTextColumn Header="MinVar" Binding="{Binding VarMin}" Width="*" CanUserSort="False" CanUserResize="True" /> </DataGrid.Columns> </DataGrid>
在DataGrid里面就很好解决了,只需要在最后一列里面的width设置时,设置为 Width="*" 最后一列就会自动填充满。