Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NTTabPage lifecycle hooks for tab page creation and destruction?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    NTTabPage lifecycle hooks for tab page creation and destruction?

    We have the OnWindowCreated(Window window) and OnWindowDestroyed(Window window) virtual methods on the AddOnBase for hooking into the NTWindow lifecycle, but are there any NTTabPage lifecycle hooks that allow me to intercept the creation and destruction of NTTabPage sub-classes?

    For example, in a Chart window when I click the "+" tab and create a new chart I want to intercept the creation of the ChartTab (a sub-class of NTTabPage) so I can set properties and subscribe to events on the newly created ChartTab. Similarly, I need to intercept the destruction of the ChartTab to unsubscribe events.

    Currently I'm subscribing to the INotifyCollectionChanged event of the NTWindow.MainTabControl.Items property like this:

    Code:
            protected override void OnWindowCreated(Window window)
            {
                base.OnWindowCreated(window);
    
                if (window is Chart chartWindow)
                {
                    var chartWindowMainTabControl = chartWindow.MainTabControl;
    
                    _tabControlCollectionView = CollectionViewSource.GetDefaultView(chartWindowMainTabControl.Items);
                    _tabControlCollectionView.CollectionChanged += TabControlOnCollectionChanged;
                }
            }
    ​
    But when a new tab is created and handled in the CollectionChanged event handler the TabItem.Content property is null and not set with the newly created ChartTab so there's no way to set its properties or subscribe to its events.

    Please advise how I can do this? Thanks.
    Attached Files

    #2
    Hello tcdouglas,

    You could use a Timer to get the added tab after it has loaded. The removed tab can be found using the event you have shown since it is already loaded. I have attached a small sample of finding the added tab.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X