我正在使用CellTemplate中的TextBlock和CellEditingTemplate中的ComboBox创建一个DataGridTemplateColumn。我通过FrameworkElementFactory创建所有这些
对于CellEditingTemplate,我从一个Grid开始,为每个需要显示的属性添加一列
每列包含一个包含TextBlock控件的Border控件;所有控件的HorizontalAlignment都设置为' Stretch'。
在网格上,IsSharedSizeScopeProperty设置为' true':
FrameworkElementFactory gf = new FrameworkElementFactory(typeof(Grid));
gf.SetValue(Grid.IsSharedSizeScopeProperty, true);
对于每列,设置SharedSizeGroup属性:
var colDef = new FrameworkElementFactory(typeof(ColumnDefinition));
colDef.SetValue(ColumnDefinition.SharedSizeGroupProperty, Convert.ToChar(65 + i).ToString());
不幸的是,最右边一列的显示是粗糙的:
如何在每一行上使每列的大小相同? (我认为这是SharedSizeGroup属性的作用。)
感谢您的任何提示 -