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

NTWindow w/out TabControl?

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

    NTWindow w/out TabControl?

    Dear NT Team / All,

    The example in helpguide for NTWindow has the following lines:
    // TabControl should be created for window content if tab features are wanted
    TabControltc=newTabControl();
    This suggests that NTWindow can be used without a tab control. Assuming I would indeed like to have a window w/out tabs (or tabcontrol), which element of NTWindow is capable of holding XAML? I don't think that NTWindow.Content acts is a container for XAML elements like Grid.

    Thanks,
    Roman

    #2
    Hello roman_ch,

    Thank you for your note.

    At the following link you can import the Sample Addon Framework,


    That example will have tabs, however you could change the following line,

    Code:
    TabControlManager.SetCanAddTabs(tc, true);
    To,

    Code:
    TabControlManager.SetCanAddTabs(tc, [B]false[/B]);
    And tabs will not be allowed to be created. This would be the easiest means of going about preventing the creation of new tabs in your chart window.

    Xaml for this addon is Saved in AddOnFrameworkTab.xaml.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Alan, thanks for taking time to respond. But this is obvious and I am not sure if my original Q was unclear.

      It does not stike me as good use of time and resource to create a TabControl and a then add a Page to it for an NTWindow that needs not tabs. The helpguide in fact implies that this is not necessary.

      So is there a way to use an NTWindow w/out a TabControl? If yes, which NTWindow element takes WPF controls?

      Thank you,
      Roman

      Comment


        #4
        Hello Roman,

        The NTWindow itself is a wpf Window which can host control elements directly.

        You can also add a Page if you want.

        Below are links to a few examples I've made.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          Thank you, that's excellent. Much appreciated.

          Regards,
          Roman

          Comment


            #6
            Hi Chelsea,

            Thanks again for your reply. I have tested and, yes, NTWindow accepts WPF through Content and Page, just as you said. I have some follow up though - please could you take a look at the below.

            The problem I was trying to resolve initially is my WPF windows not being closed / re-opened when workspaces are changed. I am not using these windows as part of an add-on (it would not be consistent with my model).

            Obviously, NTWindow in the example implements IWorkspacePersistence interface. However, I've run into problems in testing just now with that.

            Accordingly, could you let me know what exactly is required for an NTWindow (which is not part of add-on) so it is closed/re-opened with a change in the active workspace?

            Thank you,
            Roman
            Last edited by roman_ch; 02-12-2018, 06:12 AM.

            Comment


              #7
              Hi Roman,

              I have an example of this as well.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hello Chelsea,

                Thank you. Appreciate you following up with this.

                I have looked at the example, I stand to be corrected, but I think all NTWindows were created as part of an Add-On. Separately, I've run into to some issues with testing NTWindow (error re using "+" in a name, seems it is about internal names, though, as I do not have any such names).

                To help me to figure out what might be the culprit, could you explain, how an NTWindow "syncs" with the worspace re activation.Can it be done w/out using an Add-On?

                OK, I can see the interface re WorkspaceOptions, Restore() and Save(). And my guess that Restore and Save are called when Workspace is saved/restored, but I am not sure if that is what happens when Workspace changes. Same goes for Loaded (could it be something like Window.Hide() internally; and all my window data is bound to properties anyway.)

                I think it all goes to the Q which bit of code "hides" the window?

                Regards,
                Roman

                Comment


                  #9
                  Hello Roman,

                  There are no exposed NinjaTrader methods that activate when the workspace is changed and the windows visibility are changed.

                  But you might try adding a method to the IsVisibilityChanged event of the window object..


                  I'm not quite certain what you are trying to accomplish. What action are you trying to trigger when the visibility of a window is set back to visible?


                  Regarding the workspace options, just by your class inheriting from the IWorkspacePersistence interface, this causes ninjatrader to save the created NTWindow object of your class that has the interface applied when the workspace is saved.

                  When the workspace is opened, any NTWindow objects that had the interface applied are recreated.

                  Then once the window is created, NinjaTrader then trigger the Restore and Save methods so that you can set the saved values of the wpf elements and other things you wanted saved with that NTWindow.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chelsea,

                    Thank you.

                    There are no exposed NinjaTrader methods that activate when the workspace is changed and the windows visibility are changed.
                    I recall, think there is a developement request submitted for that.

                    The problem I am trying to resolve: my custom windows remain on-screen when I switch between two active workspaces (not closing any wrksp-s). I've attached two simple scripts to illustrate. The first scripts uses WPF. The second - NTWindow. Other than the base class, identical.

                    The WPF script works fine except that the window remains on-screen when I switch between active workpaces.

                    Re second script there are two items:
                    1. it generates a default re using "+" in a name, as per the screenshot. I do not see what causes this. Could you test it?
                    2. if it is made to work, and the interface implementation lines are uncommented, will the NT window be hidden when the active workspace is switched to another?

                    Thank you,
                    Roman
                    Attached Files

                    Comment


                      #11
                      Hello Roman,

                      From my understanding the core code in NinjaTrader will set the visibility of NTWindows to collapsed and will not work with other class types.

                      This is also true for the workspace persistence.


                      When you mention "it generates a default re using "+" in a name, as per the screenshot. I do not see what causes this. Could you test it?", what you are referring to here?

                      Are you talking about the string you are using for the workspace options instance?

                      Are you talking about the caption of the window?


                      Yes, even without workspace persistence implemented all NTWindows will still have the visibility set when the workspace is changed.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Chelsea,

                        When you mention "it generates a default re using "+" in a name, as per the screenshot. I do not see what causes this. Could you test it?", what you are referring to here?
                        I cannot make that code run at all. The screenshot shows the NTWindow script applied to the chart and below the log message I get in the control center.

                        Are you talking about the string you are using for the workspace options instance?
                        No

                        Are you talking about the caption of the window?
                        No

                        Yes, even without workspace persistence implemented all NTWindows will still have the visibility set when the workspace is changed.
                        The NTWindow script does not run so I cannot test this. I am am without a clue what causes the default message and the exception. But it did run previously w/out the persistence interface (when you first replied with the AddOn example). However, then the NTWindow remained visible on workspace change.

                        So the Qs now are:
                        1. Does the NTWindow script I've sent work on your machine? 2. If yes, does the NTwindow collapse when active workspace changes?

                        R
                        EDIT: just tested, it is possible indeed to hook up to IsVisibleChanged and use that to manage WPF windows - thank you. Still be good to know re above two Qs.
                        Last edited by roman_ch; 02-13-2018, 08:02 PM.

                        Comment


                          #13
                          Hello Roman,

                          The MyNTWinTest script has the TestNTWindow within the indicator class..

                          Move this to the Addons namespace.

                          Below is a link to an example.
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Mindset, 05-06-2023, 09:03 PM
                          10 responses
                          262 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by michi08, 10-05-2018, 09:31 AM
                          5 responses
                          741 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by The_Sec, Today, 02:29 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post The_Sec
                          by The_Sec
                           
                          Started by tsantospinto, 04-12-2024, 07:04 PM
                          4 responses
                          62 views
                          0 likes
                          Last Post aligator  
                          Started by sightcareclickhere, Today, 01:55 PM
                          0 responses
                          1 view
                          0 likes
                          Last Post sightcareclickhere  
                          Working...
                          X