C# WPF Datagrid列宽代码隐藏
我想替换以下xaml代码: 代码隐藏中的C# WPF Datagrid列宽代码隐藏,c#,wpf,datagrid,C#,Wpf,Datagrid,我想替换以下xaml代码: 代码隐藏中的。这个xaml代码用我的样式将我的头一直填充到最后 这就是我想要的: |名称|编号|此区域使用“mystyle”网格结尾->| 这是我目前得到的: |名称|编号|无样式区域!网格结束->| 如您所见,我想用我的样式填充未设置样式的区域,使用xaml完成此操作: 现在我需要它在cb中 好吧,我知道这有点晚了,但我也遇到了同样的问题,我使用DataGridLengthunitype.Star解决了这个问题(实际上我使用的是Grid,但应该是一样的) 你的代码
。这个xaml代码用我的样式将我的头一直填充到最后
这就是我想要的:
|名称|编号|此区域使用“mystyle”网格结尾->|
这是我目前得到的:
|名称|编号|无样式区域!网格结束->|
如您所见,我想用我的样式填充未设置样式的区域,使用xaml完成此操作:
现在我需要它在cb中 好吧,我知道这有点晚了,但我也遇到了同样的问题,我使用DataGridLengthunitype.Star解决了这个问题(实际上我使用的是Grid,但应该是一样的)
你的代码没有显示。把你的代码放在一个代码示例块中,在发布之前检查预览。我已经试过了,它不起作用。例如,如果我在表格中调整网格大小,标题会增长,但没有样式。我的答案只针对列宽部分。至于风格,你想采用哪种风格?您可以设置dataGrid.Style、dataGrid.ColumnHeaderStyle、dataGridTextColumn.ElementStyle或dataGridTextColumn.CellStyle
tc.Width = New DataGridLength(1.0, DataGridLengthUnitType.Auto);
tc.Width = New DataGridLength(2.0, DataGridLengthUnitType.Star); // this will make the colum to be twice as big as the others