Skip to main content
.NET Framework 4.5.2+

Read and Set Values for Built-in Application Model Nodes in Code

  • 3 minutes to read

The Application Model has a tree structure. You can iterate through the tree to access the required node. To access the root Application Model node, use the XafApplication.Model property.

The following XAF classes also have the Model property to provide access to the corresponding node in the Application Model:

Object Property
XafApplication XafApplication.Model
View View.Model
ActionBase ActionBase.Model
PropertyEditor PropertyEditor.Model

Application Model nodes implement the IModelNode interface. You can use IModelNode members to get parent and child nodes.

Application Model nodes also implement other interfaces with specific properties. To access properties that are specific to a particular node, cast this node to one of the interfaces that it implements. For example, the root Application node implements the IModelApplication node interface. You can cast this node to the IModelApplication type and access the IModelApplication.Logo property. You can also cast the Application node to the IModelApplicationNavigationItems type and access the NavigationItems property. See the following topic for more information on available interfaces: Application Model: Built-in Interfaces.


The examples below make changes in the top layer of the Application Model (the user customization layer). Use the techniques from the following topic to customize the underlying zero layer: How to: Extend and Access the Application Model Nodes from Controllers.

Customize a Root Application Node

The following example accesses the root Application node and uses the IModelRootNavigationItems.StartupNavigationItem property to show the Department_ListView View at application startup.

using DevExpress.ExpressApp.SystemModule;  
using System.Linq;  
// ...  
    private void MainDemoWinApplication_LoggedOn(object sender, LogonEventArgs e) {  
        XafApplication app = (XafApplication)sender;  
        IModelApplicationNavigationItems navigationItems = (IModelApplicationNavigationItems)app.Model;  
        string targetViewId = "Department_ListView";  
        IModelNavigationItem targetNavigationItem = navigationItems.NavigationItems.AllItems.FirstOrDefault(
            item => item.View?.Id == targetViewId);
        if(targetNavigationItem != null) {  
            navigationItems.NavigationItems.StartupNavigationItem = targetNavigationItem;  
// ...  

Customize a Business Object Node

The code below shows how to access the Contact business class and change its Caption:

using System.Linq;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;

namespace YourSolutionName.Module.Controllers {
    public class CustomController : ViewController {
        public CustomController() {
            var myAction1 = new SimpleAction(this, "MyAction1", null);
            myAction1.Execute += MyAction1_Execute;

        private void MyAction1_Execute(object sender, SimpleActionExecuteEventArgs e) {
            var bo = Application.Model.BOModel.GetClass(typeof(Contact));
            if(bo != null) {
                var oldCaption = bo.Caption;
                bo.Caption = "New test caption";


The XAF UI does not reflect changes made in the Application Model after control creation. Customize the Application Model before the control used to display a target UI element is created and loaded. Access the control directly to customize a UI element after the control’s creation. Refer to the following topic for more information: How to: Access the Grid Component in a List View.

You can also recreate the control with the latest Application Model changes as described in the following topic: Apply Application Model Changes to the Current View Immediately.

See Also