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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.JimNinjaTrader Customer Service
-
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:
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.JimNinjaTrader Customer Service
- Likes 1
Comment
-
Originally 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 bortz, 11-06-2023, 08:04 AM
|
47 responses
1,607 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
6 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
16 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment