Is there an event I can subscribe to that will fire when the tab change is fully complete and the new chart is loaded and available?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
After tab changed event
Collapse
X
-
After tab changed event
I'm trying to get my chart trader customisations working with Tabs. I'm subscribing to the SelectionChanged event on chart.MainTabControl. However when this event Fires only the tab has changed, the ActiveChartControl hasn't yet been changed and is still registered as the old tab.
Is there an event I can subscribe to that will fire when the tab change is fully complete and the new chart is loaded and available?
Tags: None
-
Hello kevinenergy,
Thanks for your post.
This functionality should be mapped out in NinjaTrader_Chelsea's SampleWPFModifications example. MainTabControl.SelectionChanged would be used and you may also note how the TabSelected bool is implemented.
The sample can be found in our Help Guide here - https://ninjatrader.com/support/help...ui)-modifi.htm
The original thread with smaller scripts that can focus on individual UI modifications can be found here - Modifications to chart WPF elements and tab considerations - NinjaTrader Support Forum
If there is some different functionality you are after that is not demonstrated with the example, could you elaborate on what you are trying to do differently?
We look forward to assisting.
-
Hi Jim,
Essentially I am trying to do the same thing but not from an Indicator. I'm using the context of an Addon to the "Chart" window object. I do much of the same things in Chelsea's example.
I note that in Chelsea's example he's using the TabItem instance, provided by TabChange handler to determine if tab.Content.ChartControl is equal to the ChartControl of the indicator.
As my code is running in the context of the window, and not an indicator, I need to rely on chart.ActiveChartControl to get the currently active ChartControl in order to do this comparison.
However, at the point when the TabChangeHandler is run, the chart.ActiveChartControl has not yet update and still points to previous tab's ChartControl. I see this event is triggered from the base type System.Windows.Controls.ItemsControl, so it stands to reason that this event probably fires quite early in the chain of events that cause the new chart to load.
So my question is: Is there another event that I can hook into a bit later where chart.ActiveChartControl will have been updated? My code references _chart.ActiveChartControl in several places places.
So far, I've just switched off tabs completely, but I would like to get some coding done over the Christmas period and this is something I would like to get fixed finally.
Last edited by kevinenergy; 12-27-2021, 09:26 AM.
Comment
-
Hello kevinenergy,
There will be more implications when implementing that functionality in an AddOn, and we have not navigated those areas with our own example.
To touch on the ActiveChartControl part, If I test the following in the SampleWPFModifications TabSelected() bool:
It appears that chartWindow.ActiveChartControl.GetHashCode() is always "lagging" when switching tabs, but ((chartWindow.MainTabControl.Items.GetItemAt (chartWindow.MainTabControl.SelectedIndex) as TabItem).Content as ChartTab).ChartControl.GetHashCode()) is pointing to the intended tab once changed.Code:Print(""); Print(((chartWindow.MainTabControl.Items.GetItemAt (chartWindow.MainTabControl.SelectedIndex) as TabItem).Content as ChartTab).ChartControl.GetHashCode()); Print(chartWindow.ActiveChartControl.GetHashCode());
You may want to try getting ChartControl in similar way to have it work nicely in an AddOn.
If this helps, it may be beneficial to share your changes with the community.Last edited by NinjaTrader_Jim; 12-29-2021, 09:08 AM.
- Likes 1
Comment
-
You have to wait for Loaded event for selected Tab Page, and then make any actionsOriginally posted by kevinenergy View PostHi Jim,
Essentially I am trying to do the same thing but not from an Indicator. I'm using the context of an Addon to the "Chart" window object. I do much of the same things in Chelsea's example.
I note that in Chelsea's example he's using the TabItem instance, provided by TabChange handler to determine if tab.Content.ChartControl is equal to the ChartControl of the indicator.
As my code is running in the context of the window, and not an indicator, I need to rely on chart.ActiveChartControl to get the currently active ChartControl in order to do this comparison.
However, at the point when the TabChangeHandler is run, the chart.ActiveChartControl has not yet update and still points to previous tab's ChartControl. I see this event is triggered from the base type System.Windows.Controls.ItemsControl, so it stands to reason that this event probably fires quite early in the chain of events that cause the new chart to load.
So my question is: Is there another event that I can hook into a bit later where chart.ActiveChartControl will have been updated? My code references _chart.ActiveChartControl in several places places.
So far, I've just switched off tabs completely, but I would like to get some coding done over the Christmas period and this is something I would like to get fixed finally.
- Likes 1
Comment
-
Thanks both for the info, I'm going to pick this up again over the next couple of days and will let you know how I get on.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
581 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
338 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment