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!
See more
See less

Partner 728x90

Collapse

Create a toolbar in a custom NTWindow

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Create a toolbar in a custom NTWindow

    How do I add buttons to the header toolbar of a custom NTWindow?

    I've tried putting this in my code, but a and b are both coming back as null, so I don't know how to add items to the top menu.

    Code:
    public class MyWindow : NTWindow, IWorkspacePersistence {
        public MyWindow() {
            Loaded += (o, e) => {
                if (WorkspaceOptions == null) WorkspaceOptions = new WorkspaceOptions("MyWindow-" + Guid.NewGuid().ToString("N"), this);
                var a = this.FindFirst("PART_Menu");
                var b = this.FindName("PART_Menu");
            };
        }
    ...
    }
    If there is a code solution and a resx solution, I'd love to see both.
    Thanks in advance

    #2
    Well, things just got simpler ... when I discovered the "MainMenu" property ... lol, thanks

    Comment


      #3
      I am glad you were able to find a resolution to your query. For reference, here is a relevant section of the help guide.

      Jessica P.NinjaTrader Customer Service

      Comment


        #4
        Hi there,

        I've added the NT InstrumentSelector to the header toolbar like this:

        public class AddOnFrameworkWindow : NTWindow, IWorkspacePersistence
        {
        public AddOnFrameworkWindow()
        {

        ...

        InstrumentSelector instrumentSelector = new InstrumentSelector();
        MainMenu.Add(instrumentSelector);


        Works fine but how can I attach the private event handler AddOnPage.OnInstrumentChanged to the Instrument selector?

        And I'm curious to know the purpose of InstrumentSelector.LastUsedGroup.

        Many thanks!

        Comment


          #5
          I can imagine two solutions. You as a developer may end up coming up with others
          • Make this a public or protected method instead of a private method.
          • Set up your event handler to remain private, but to also access publicly available members of your class, or passed-in event arguments

          The attached script should help you get started with the second approach. It shows how to set up a custom EventArgs structure, and also shows how to dispatch to another object's thread. In this case the thread used is the main UI thread. However if you review the publicly available MSDN documentation for Dispatcher.Invoke, you should be able to easily dispatch to your class or your instrument selector's threads.


          Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.
          Attached Files
          Jessica P.NinjaTrader Customer Service

          Comment


            #6
            Many thanks for your reply.
            I think I need for both solutions in NTWindow a reference to an instance of my NTTabPage class. Is there a collection or list of NTTabPages in NTWindow available?
            Or how can I reference in my NTTabPage to the parent window container NTWindow ?

            Comment


              #7
              While we do not make this information publicly available, beyond what is in the documentation, generally we do provide some information my colleague Jesse put together which is useful for using the inspect tool to learn more about the platform.



              Between this and the IntelliSense tool that comes with the editor, you should be able to discover enough in the way of information with any existing NinjaTrader window to be able to hook into its functionality.
              Jessica P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by The_Sec, Today, 02:29 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by jeronymite, 04-12-2024, 04:26 PM
              2 responses
              30 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by Mindset, 05-06-2023, 09:03 PM
              10 responses
              265 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by michi08, 10-05-2018, 09:31 AM
              5 responses
              743 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by tsantospinto, 04-12-2024, 07:04 PM
              4 responses
              63 views
              0 likes
              Last Post aligator  
              Working...
              X