Exemplo n.º 1
0
        /// <summary>
        /// 生成GridTreeView列对象
        /// </summary>
        /// <param name="meta"></param>
        /// <returns></returns>
        public TreeColumn Create(WPFEntityPropertyViewMeta meta)
        {
            //根据editorName生成对应的Column
            var treeColumn = this.CreateInstance(meta.GetEditorNameOrDefault()) ?? new CommonTreeColumn();

            treeColumn.Meta = meta;

            var editor = this._propertyEditorFactory.Create(meta, true);

            treeColumn.Editor = editor;

            //使用 PropertyEditor 来生成 Binding 的原因是:
            //如果是下拉框、则不能直接使用默认的绑定方案。
            treeColumn.Binding = CreateBindingByEditor(editor);

            treeColumn.HeaderLabel           = (meta.Label ?? meta.Name).Translate();
            treeColumn.PropertyName          = meta.Name;
            treeColumn.SortingProperty       = meta.DisplayPath();
            treeColumn.DisplayTextBlockStyle = TypeHelper.IsNumber(TypeHelper.IgnoreNullable(meta.PropertyMeta.Runtime.PropertyType)) ?
                                               RafyResources.TreeColumn_TextBlock_Number : RafyResources.TreeColumn_TextBlock;

            //宽度
            if (meta.GridWidth.HasValue)
            {
                treeColumn.Width = meta.GridWidth.Value;
            }

            return(treeColumn);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据属性元数据中指定的 EditorName 生成属性编辑器
        /// </summary>
        /// <param name="property"></param>
        /// <param name="forList"></param>
        /// <returns></returns>
        public PropertyEditor Create(WPFEntityPropertyViewMeta property, bool forList)
        {
            var result = this.CreateInstance(property.GetEditorNameOrDefault(), true) ??
                         this.CreateInstance(WPFEditorNames.String, true);

            this.InitPropertyEditor(result, property, forList);

            return(result);
        }