OnWindowDestroyed()
<< Click to Display Table of Contents >> OnWindowDestroyed() |
This method is called whenever a new NTWindow is destroyed. It will be called in the thread of that window. A window is destroyed either by the user closing the window, closing a workspace, or on a shut down of NinjaTrader.
Note: This method will also be called on a recompile of the NinjaTrader.Custom project (e.g., when you compile an indicator, strategy, or add-on) |
This method does not return a value
OnWindowDestroyed(Window window)
window |
A Window object which is being removed from the workspace |
public class MyWindowAddOn : AddOnBase { private NTMenuItem myMenuItem; private NTMenuItem existingMenuItem;
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = "Our custom MyWindow add on"; Name = "MyWindow"; } }
// Will be called as a new NTWindow is destroyed. It will be called in the thread of that window protected override void OnWindowDestroyed(Window window) { if (myMenuItem != null && window is ControlCenter) { if (existingMenuItem != null && existingMenuItem.Items.Contains(myMenuItem)) existingMenuItem.Items.Remove(myMenuItem);
myMenuItem.Click -= OnMenuItemClick; myMenuItem = null; } } } |