Example E372
Visible to All Users

XAF - How to access a tab control in a Detail View layout

This example implements a View Controller that accesses layout controls and customizes them as required. In particular, the second tab in the tab control should become active when the detail form is opened.

WinForms

Du2Er0SPZV

ASP.NET Core Blazor

|image

Implementation Details

  1. This functionality is implemented in the WinCustomizeTabControlViewController.cs and BlazorCustomizeTabControlViewController.cs classes, added to the WinForms and Blazor application projects respectively. Copy these classes to the corresponding projects in your test solution.
  2. To identify the layout element by the MyTabbedGroup string, make sure this identifier is specified under the Views | YourBusinessObject_DetailView | Layout node in the Model Editor (invoked for the YourSolutionName.Module/Model.DesignedDiffs.xafml file).

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

EFCore/AccessLayoutEF/AccessLayoutEF.Win/Controllers/WinCustomizeTabControlViewController.cs
C#
using System; using DevExpress.ExpressApp; using DevExpress.XtraLayout; using DevExpress.ExpressApp.Win.Layout; namespace AccessLayout.Win { public class WinCustomizeTabControlViewController : ViewController<DetailView> { TabbedControlGroup tabbedGroup; WinLayoutManager layoutManager; protected override void OnActivated() { base.OnActivated(); layoutManager = (WinLayoutManager)View.LayoutManager; layoutManager.ItemCreated += OnItemCreated; layoutManager.LayoutCreated += OnLayoutCreated; } void OnItemCreated(object sender, ItemCreatedEventArgs e) { // Check this Id in the AccessLayoutEF.Module/Model.DesignedDiffs.xafml file if (e.ModelLayoutElement.Id == "MyTabbedGroup") { tabbedGroup = (TabbedControlGroup)e.Item; } } private void OnLayoutCreated(object sender, EventArgs e) { if (tabbedGroup != null) { tabbedGroup.SelectedTabPageIndex = 1; } } protected override void OnDeactivated() { if (layoutManager != null) { layoutManager.ItemCreated -= OnItemCreated; layoutManager.LayoutCreated -= OnLayoutCreated; layoutManager = null; } tabbedGroup = null; base.OnDeactivated(); } } }
EFCore/AccessLayoutEF/AccessLayoutEF.Blazor.Server/Controllers/BlazorCustomizeTabControlViewController.cs
C#
using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Blazor.Components.Models; using Microsoft.AspNetCore.Components; using DevExpress.ExpressApp.Blazor.Layout; namespace AccessLayoutEF.Blazor { public class BlazorCustomizeTabControlViewController : ViewController<DetailView> { BlazorLayoutManager layoutManager; protected override void OnActivated() { base.OnActivated(); layoutManager = (BlazorLayoutManager)View.LayoutManager; layoutManager.ItemCreated += OnItemCreated; } private void OnItemCreated(object sender, BlazorLayoutManager.ItemCreatedEventArgs e) { if (e.ModelLayoutElement.Id == "MyTabbedGroup" && e.LayoutControlItem is DxFormLayoutTabPagesModel tabbedGroup) { tabbedGroup.ActiveTabIndex = 1; tabbedGroup.ActiveTabIndexChanged = EventCallback.Factory.Create<int>(this, index => tabbedGroup.ActiveTabIndex = index); } } protected override void OnDeactivated() { if (layoutManager is not null) { layoutManager.ItemCreated -= OnItemCreated; layoutManager = null; } base.OnDeactivated(); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.