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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    92 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    122 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X