【问题标题】:specify a property editor inside the business object在业务对象内指定一个属性编辑器
【发布时间】:2016-09-30 08:10:45
【问题描述】:

我正在使用 Dev Express XAFEntity framework。 我希望能够指定我的Description 字段使用属性编辑器DevExpress.ExpressApp.HtmlPropertyEditor.Win.HtmlPropertyEditor

我可以通过在涉及该字段的视图中设置 model.xafml 内的属性编辑器来做到这一点。但是,我更愿意在 business 对象中将其设置一次作为属性。

有没有办法做到这一点?

【问题讨论】:

    标签: entity-framework devexpress xaf


    【解决方案1】:

    DevExpress 知识库在这里解释了如何实现这一点:KA18907。请参阅第 2.2 和 2.3 节。

    如果您的业务对象与编辑器在同一个模块中声明,那么您可以这样做:

    //Class declared in a WinForms module, for example
    public class BusinessObject : BaseObject {
        ...
        [ModelDefault("PropertyEditorType", "SampleSolution.Module.Win.PropertyEditors.CustomStringEditor")]
        public string Description {
            get { return GetPropertyValue<string>("Description"); }
            set { SetPropertyValue<string>("Description", value); }
        }
    }
    

    否则,请改用EditorAlias 属性。

    public class BusinessObject : BaseObject {
        ...
        [EditorAlias("CustomStringEdit")]
        public string Description {
            get { return GetPropertyValue<string>("Description"); }
            set { SetPropertyValue<string>("Description", value); }
        }
    }
    

    并在您的编辑器中设置相同的字符串标识符。 (这允许为不同的编辑器指定单独的 Web 和 Win 模块)。

    [PropertyEditor(typeof(String), "CustomStringEdit", false)]
    public class CustomStringEditor : StringPropertyEditor {
        public CustomStringEditor(Type objectType, IModelMemberViewItem info)
            : base(objectType, info) {  }
        ...
    }
    

    【讨论】:

    • 我在平台无关模块中声明了业务对象。我需要它,因为这是实体框架上下文所在的位置。
    • 所以请使用EditorAlias,如 2.3 中所述。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多