我有几列的数据网格,我希望其中一个总是填充此数据网格的空白空间。我可以更改此代码以获得此结果吗?不幸的是,这不是我的代码
<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>
答案 0 :(得分:4)
为您的某个DataGridTemplateColumn设置Width="*"
。
<data:DataGridTemplateColumn CanUserSort="True"
SortMemberPath="EscalateTypeId"
Width="*">
答案 1 :(得分:0)
我希望有一个相当于以下的银光,如果没有帮助,不要仅仅评论这样的评论,我将删除;
dataGridView1.AutoGenerateColumns = false;
DataGridViewColumn column = new DataGridViewColumn();
column.DataPropertyName = "Question Number";
column.HeaderText = "Question Number";
column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns.Add(column);
// Summary:
// The column width adjusts so that the widths of all columns exactly fills
// the display area of the control, requiring horizontal scrolling only to keep
// column widths above the System.Windows.Forms.DataGridViewColumn.MinimumWidth
// property values. Relative column widths are determined by the relative System.Windows.Forms.DataGridViewColumn.FillWeight
// property values.