-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlazorCustomizeTabControlViewController.cs
29 lines (28 loc) · 1.22 KB
/
BlazorCustomizeTabControlViewController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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();
}
}
}