Telerik.Windows.Controls.GridViewColumn gvc = new Telerik.Windows.Controls.GridViewColumn();
TextBlock tb = new TextBlock();
if (_zYXTabList[i].ZhuLuType == "1" || _zYXTabList[i].ZhuLuType == "3")
{//文字选择1,数字选择3
DataTemplate nameTemplate = new DataTemplate();
FrameworkElementFactory nameFactory = new FrameworkElementFactory(typeof(RadComboBox));
EditFramePage efp = new EditFramePage();
ArrayList al = new ArrayList();//把数据源中显示内容提取出来放到al中
foreach (CiTiao ct in efp.GetCitiaoListByOptionID(_zYXTabList[i].XuanXiangID))
{
al.Add(ct.CiTiaoName);
}
Binding binding = new Binding();
binding.Source = al;
//binding.Mode = BindingMode.TwoWay;
nameFactory.SetBinding(RadComboBox.ItemsSourceProperty, binding);
nameTemplate.VisualTree = nameFactory;
nameTemplate.Seal();
gvc.CellTemplate = nameTemplate;
gvc.Header = _zYXTabList[i].Name;
TabGrid.Columns.Add(gvc);
这篇博客介绍了如何在WPF中动态地添加GridViewColumn,并结合DataTemplate绑定到RadComboBox控件。通过示例代码展示了根据条件判断,为不同的列设置数据源,并实现与RadComboBox的双向数据绑定。
7132

被折叠的 条评论
为什么被折叠?



