组合框中的多列 - 宽度相同

时间:2016-04-25 15:43:59

标签: c# wpf combobox datagridtemplatecolumn

我正在使用CellTemplate中的TextBlock和CellEditingTemplate中的ComboBox创建一个DataGridTemplateColumn。我通过FrameworkElementFactory创建所有这些 对于CellEditingTemplate,我从一个Grid开始,为每个需要显示的属性添加一列 每列包含一个包含TextBlock控件的Border控件;所有控件的Horizo​​ntalAlignment都设置为' 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());

不幸的是,最右边一列的显示是粗糙的:
enter image description here
如何在每一行上使每列的大小相同? (我认为这是SharedSizeGroup属性的作用。)
感谢您的任何提示 -

0 个答案:

没有答案