2016-06-01 50 views
2

我正在使用Dev ExpressXAFEntity framework。 我希望能夠指定我Description字段使用屬性編輯器DevExpress.ExpressApp.HtmlPropertyEditor.Win.HtmlPropertyEditor指定業務對象內的屬性編輯器

我可以通過設置在涉及該領域的意見裏面model.xafml屬性編輯器做到這一點。不過,我寧願只在business對象中將其設置爲屬性。

有沒有辦法做到這一點?

回答

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) { } 
    ... 
} 
+0

我有在平臺獨立模塊中聲明的業務對象。我需要它,因爲這是實體框架上下文所在的位置。 –

+1

所以使用'EditorAlias'如2.3所述。 – shamp00