NTTabPage Class
This is where the actual content for tabs inside the custom add on NTWindow can be defined.
A class derived from NTTabPage has to be created if instrument link or interval link functionality is desired. IInstrumentProvider and IIntervalProvider interfaces should be implemented as well to ensure proper linking.
| Method | Description |
|---|---|
| Cleanup() | Unregisters LinkControls and calls Cleanup() on ICleanable controls on the NTTabPage |
| GetHeaderPart() | Indicates the tab header name. |
| Restore() | Restores any elements in our NTTabPage from the workspace. |
| Save() | Saves elements in our NTTabPage to the workspace. |
Examples
public class MyWindowTabPage : NTTabPage, NinjaTrader.Gui.Tools.IInstrumentProvider, IIntervalProvider{private Instrument instrument;public MyWindowTabPage(){/* Define the content for our NTTabPage. We can load loose XAML to define controls and layoutsif we so choose here as well.Note: XAML with event handlers defined inside WILL FAIL when attempted to load.Note: XAML with "inline code" WILL FAIL when attempted to load */}// Called by TabControl when a tab is being removed or window is closedpublic override void Cleanup(){/* Unsubscribe and clean up resources used by the tab that just closed. You may haveresources you don't want to clean up just yet because the window is still being used */}// NTTabPage member. Required for determining the tab header nameprotected override string GetHeaderPart(string variable){// Determine the text for the tab header namereturn variable;}// NTTabPage member. Required for restoring elements from workspacesprotected override void Restore(System.Xml.Linq.XElement element){if (element == null)return;// Restore any elements you may have saved. e.g. selected accounts or instruments}// NTTabPage member. Required for saving elements to workspacesprotected override void Save(System.Xml.Linq.XElement element){if (element == null)return;// Save any elements you may want persisted. e.g. selected accounts or instruments}// IInstrumentProvider memberpublic Instrument Instrument{get { return instrument; }set{if (instrument != null){// Unsubscribe to subscriptions to previously selected instrument}if (value != null){// Create subscriptions for the newly selected instrument}instrument = value;// Update the tab header nameRefreshHeader();}}// IIntervalProvider memberpublic BarsPeriod BarsPeriod { get; set; }}