예제 #1
0
        // 重置列信息
        private void _ResetColumns(IEnumerable cloumns)
        {
            this.treeList.Columns.Clear();
            if (cloumns == null)
            {
                return;
            }
            DataTemplate template = null;

            foreach (IGridViewColumn c in cloumns)
            {
                DevExpress.Xpf.Grid.TreeListColumn column = new DevExpress.Xpf.Grid.TreeListColumn();
                column.Header = c.Header;
                column.Width  = c.Width;
                if (c.IsSort && !c.FieldName.IsNullOrEmptyOrWhiteSpace())
                {
                    column.FieldName = c.FieldName;
                }
                DataTemplate temp = null;
                IGridViewCellTemplateProvider _proverder = null;
                foreach (IGridViewCellTemplateProvider proverder in this._providers)
                {
                    temp = proverder.CreateCellTemplate(c);
                    if (temp != null)
                    {
                        template   = temp;
                        _proverder = proverder;
                    }
                }
                if (_proverder == null || template == null)
                {
                    throw new Exception("No suitable proverder.");
                }
                column.CellTemplate = template;
                column.Tag          = c;
                c.Column            = column;
                Binding binding = new Binding();
                binding.Source = c;
                binding.Path   = new PropertyPath("IsVisible");
                column.SetBinding(GridColumn.VisibleProperty, binding);
                this.treeList.Columns.Add(column);
            }
        }
예제 #2
0
 /// <summary>
 /// 移除单元格模版生成器
 /// </summary>
 /// <param name="provider">列样式生成器</param>
 public void RemoveCellTemplateProvider(IGridViewCellTemplateProvider provider)
 {
     this._providers.Remove(provider);
 }
예제 #3
0
 /// <summary>
 /// 添加单元格模版生成器
 /// </summary>
 /// <param name="provider">列样式生成器</param>
 public void AddCellTemplateProvider(IGridViewCellTemplateProvider provider)
 {
     this._providers.Add(provider);
 }