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:
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 Rogers101, 05-05-2024, 11:30 AM
|
3 responses
21 views
0 likes
|
Last Post
by Rogers101
Today, 12:48 AM
|
||
Started by nightstalker, 05-04-2024, 02:05 PM
|
5 responses
53 views
1 like
|
Last Post
by nightstalker
Today, 12:13 AM
|
||
Started by MSerag, Yesterday, 11:52 PM
|
0 responses
9 views
0 likes
|
Last Post
by MSerag
Yesterday, 11:52 PM
|
||
Started by DynamicTest, Yesterday, 11:18 PM
|
0 responses
3 views
0 likes
|
Last Post
by DynamicTest
Yesterday, 11:18 PM
|
||
Started by dcriador, Yesterday, 01:43 AM
|
3 responses
21 views
0 likes
|
Last Post
by dcriador
Yesterday, 11:17 PM
|
Comment