XAF中的自定义属性编辑器2012-03-13 博客园 Junior LauXAF是什么,如果您没听说过,本文可能对你没有帮助,但如果你正在查找同样问题的解决方法希望对你有所帮助。(注:所举得例子全部是Web工程下的,Win工程原理相同)XAF自动从业务类生成UI。自动的根据业务类各属性的类型生成所需的属性编辑器。比如,对于一个业务类中的String型的属性,生成的是一个文本框(从界面看是那样)。对Datetime型的属性生成一个日期选择框。常用的属性编辑器类见下表(Web工程下):
Tpye | PropertyEditorType | 备注 |
String | DevExpress.ExpressApp.Web.Editors.ASPx.ASPxStringProertyEditor | 展示文本框 |
Int32 | DevExpress.ExpressApp.Web.Editors.ASPx.ASPxIntProertyEditor | 展示可调整的数字输入框 |
Boolean | DevExpress.ExpressApp.Web.Editors.ASPx.ASPxBooleanProertyEditor | 选中按钮 |
Datetime | DevExpress.ExpressApp.Web.Editors.ASPx.ASPxDatetimeProertyEditor | 时间框 |
Enum | DevExpress.ExpressApp.Web.Editors.ASPx.ASPxEnumProertyEditor | 下拉框 |
<BaseObject> | DevExpress.ExpressApp.Web.Editors.ASPx.ASPxLookupPropertyEditor | 下拉框,通常是同这个对象形成一对多的关系 |
在创建业务类的时候这些对象自动和业务类的属性关联,不需要再做声明。还可以选择其他的属性编辑器。可以在Xafml文件的Application | Views | Items | PropertyEditor节点或Application | Views | Items | PropertyEditor节点找到。如:与 Rating 属性相应的 Application | Views | Items | PropertyEditor 节点:
<Application>
<Views>
<DetailView ID="Song_DetailView">
<Items>
<PropertyEditor PropertyName="Rating"
PropertyEditorType="MySolution.Module.Web.MySolutionAspNetModule.WebStarRatingPropertyEditor" />
</Items>
</DetailView>
</Views>
</Application>
与 Rating 属性相应的 Application | BOModel | Class | Member 节点:
<Application>
<Views>
<DetailView ID="Song_DetailView">
<Items>
<PropertyEditor PropertyName="Rating"
PropertyEditorType="MySolution.Module.Web.MySolutionAspNetModule.WebStarRatingPropertyEditor" />
</Items>
</DetailView>
</Views>
</Application>