我在ListView的某一个coloumn里combobox,当用鼠标拖动columnheader的宽度时,如何是Combobox的宽度也相应变化?需要绑定哪个属性才能是combobox的宽度等于gridviewcolumn的宽度实时变化?
实例代码:
GridViewColumn col = new GridViewColumn();
col.Header = "FieldName";
col.Width = 120;
template = new DataTemplate();
factory = new FrameworkElementFactory((typeof(ComboBox)));
double width = col.Width - 10;
factory.SetValue(ComboBox.WidthProperty, width);
factory.SetBinding(ComboBox.TextProperty, new Binding("FieldName"));
factory.SetValue(ComboBox.IsEditableProperty, true);
itemsBinding = new Binding();
itemsBinding.Source = FiledName;
factory.SetBinding(ComboBox.ItemsSourceProperty, itemsBinding);
template.VisualTree = factory;
col.CellTemplate = template;
grdView.Columns.Add(col);
实例代码:
GridViewColumn col = new GridViewColumn();
col.Header = "FieldName";
col.Width = 120;
template = new DataTemplate();
factory = new FrameworkElementFactory((typeof(ComboBox)));
double width = col.Width - 10;
factory.SetValue(ComboBox.WidthProperty, width);
factory.SetBinding(ComboBox.TextProperty, new Binding("FieldName"));
factory.SetValue(ComboBox.IsEditableProperty, true);
itemsBinding = new Binding();
itemsBinding.Source = FiledName;
factory.SetBinding(ComboBox.ItemsSourceProperty, itemsBinding);
template.VisualTree = factory;
col.CellTemplate = template;
grdView.Columns.Add(col);
应该是DataGridView中放combobox吧!