Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
OnTabCreate / OnTabDestroy for AddOns?
Collapse
X
-
Hello gubbar924,
You can add handlers to the Loaded and Closed events in the NTTabPage class.
public class AddonWindowTabPage : NTTabPage
{
public AddonWindowTabPage()
{
Loaded += TabLoaded;
Unloaded += TabUnloaded;
}
public void TabUnloaded(object sender, System.Windows.RoutedEventArgs e)
{
NinjaTrader.Code.Output.Process("tab is loaded", PrintTo.OutputTab1);
}
public void TabLoaded(object sender, System.Windows.RoutedEventArgs e)
{
NinjaTrader.Code.Output.Process("tab is unloaded", PrintTo.OutputTab1);
}
}
This would be similar, except would trigger anytime the tab is actually being displayed (which is when the page or content for that tab loads) or being switched away from (which causes the content to unload).
I will ask our development to see if there is something created specifically when the tab is created or closed instead of when loaded or unloaded.Chelsea B.NinjaTrader Customer Service
-
Hello gubbar924,
Our development has tipped be to the following document that demonstrates how to detect when the tabitems collection changes.
I am trying to synchronize the selected tab item of a WPF tab control with the last item that was added. Since there is no such property as e.g. IsSynchedWithLastAddedItem, I am trying to detect w...
This is general C# code and is not specific to NinjaTrader and is not documented in the NT8 help guide.
The code, if added to the AddonShellWindow class would look like:
In the Constructor() after the tabControl object is created and the TabControlManager methods run:
This would trigger a method within the AddonShellWindow class.Code:System.ComponentModel.ICollectionView myView = System.Windows.Data.CollectionViewSource.GetDefaultView(tabControl.Items); myView.CollectionChanged += TabsChanged;
Code:public void TabsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { NinjaTrader.Code.Output.Process("new items: " + e.NewItems.Count.ToString(), PrintTo.OutputTab1); System.Windows.Controls.TabItem newTab = e.NewItems[0] as System.Windows.Controls.TabItem; NinjaTrader.Code.Output.Process("newTab: " + newTab.ToString(), PrintTo.OutputTab1); } if (e.OldItems != null) { NinjaTrader.Code.Output.Process("old items: " + e.OldItems.Count.ToString(), PrintTo.OutputTab1); System.Windows.Controls.TabItem oldTab = e.OldItems[0] as System.Windows.Controls.TabItem; NinjaTrader.Code.Output.Process("newTab: " + oldTab.ToString(), PrintTo.OutputTab1); } }Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
672 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment