用代码访问应用程序模型 |
|
eXpressApp Framework > Concepts > Application Model > Access the Application Model in Code
The Application Model represents a large data store which is used when running the application to generate the UI and configure the application behavior. This topic details how to access the Application Model in code, to change the application flow.
应用模型是一个大型数据存储在运行时所使用的应用程序生成用户界面和配置应用程序的行为。本主题详细介绍如何在代码中访问应用程序模型,来改变应用程序流。
The following table lists the objects which allow accessing the Application Model in code:
下表列出了允许用代码访问应用程序模型中的对象。
Object |
Property |
The IModelNode descendant object, which is returned by the Model properties presented above, provides you with access to the corresponding Application Model node. You can access a node's properties via this object. Additionally, it exposes the Application property, which represents the root Application node.
该IModelNode后裔对象,它是由上面提出的模型属性返回,为客户提供获得相应的应用模型节点上。你可以通过访问这个对象的节点的属性。此外,它列出了应用程序属性,它代表了根应用程序节点。
The following example demonstrates how to use the View.Model property to set the required value for the current ListView node's MasterDetailMode property. For this purpose, a new View Controller must be created, and a SimpleAction must be added to it. This Action will allow end-users to switch between two modes: the current List View only and the current List View together with the corresponding Detail View. So, you can call this Action "SwitchAction".
项目例子演示如何使用View.Model属性为当前列表视图节点的主从显示模式属性设置一个值。为此,你需要添加页ViewController件和一个SimpleAction按钮。这个按钮允许最终用户切换两种模式:视图列表和主从视图模式。因此,你可以用“SwitchAction”按钮切换。
|
The complete sample project is available in the DevExpress Code Central database at http://www.devexpress.com/example=E224. Depending on the target platform type (ASP.NET, WinForms, etc), you can either run this example online or download an auto-executable sample. |
Add a handler to the Switch Action's Execute event as shown below:
添加一个句柄处理按钮事件如下:
| ||||||
using DevExpress.ExpressApp.Model; // ... private void SwitchAction_Execute(object sender, SimpleActionExecuteEventArgs e) { if (((IModelListView)View.Model).MasterDetailMode == MasterDetailMode.ListViewAndDetailView) ((IModelListView)View.Model).MasterDetailMode = DevExpress.ExpressApp.MasterDetailMode.ListViewOnly; else ((IModelListView)View.Model).MasterDetailMode = DevExpress.ExpressApp.MasterDetailMode.ListViewAndDetailView; View.SetInfo(View.Model); }
|
For details on the SetInfo method, refer to the View.SetInfo method description in the Reference help section.
SetInfo方法的更详细信息,请参考View.SetInfo方法帮助篇。
This approach allows you to access properties available in the Application Model. If it is required to extend the application model with new nodes and properties, refer to the Extend and Customize the Application Model in Code topic.
这种方法允许你访问应用程序模型中可用属性。如果需要用新的节点和属性扩展应用程序模型,请参考Extend and Customize the Application Model in Code帮助主题
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/