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所述。 – shamp00