• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to add a MenuItem to the ContextMenu of an add-on deriving from NTTabpage?

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

    How to add a MenuItem to the ContextMenu of an add-on deriving from NTTabpage?

    To simplify this question, my add-on follows the exact same architecture of the "AddOn Framework" sample but much simpler with only a couple of controls. It works just fine. So if you tell me how it can be done in the AddOnFramework sample, I can take it from there.

    I tried unsuccefully
    Code:
    this.ContextMenu.Items.Add(new NTMenuItem { Header = "My New ContextMenu Item"});
    in the contructor and in several other methods in all of these classes:

    Code:
        AddOnFramework 
        AddOnFrameworkWindowFactory
        AddOnFrameworkWindow
        AddOnFrameworkTab
        TabControlManager helper methods
    Ultimately, one of these classes wraps a ContextMenu object that visually looks like the attached image in which the only menu items are the ones related to managing the tabs.

    Please help.
    Attached Files

    #2
    Hello xcondor,

    Thank you for the post.

    I wanted to check, are you trying to modify the Tab context menu that you have shown specifically or add a Context to a control you have created in the tab?

    If you are trying to append to/edit an existing context menu the platform already offers, you will very likely need to follow the approach laid out here: https://ninjatrader.com/support/foru...87&postcount=6

    If the context in question is generated dynamically, you would need to use the opening event of the context menu to modify the list.

    If this is a control of your own, you should be able to add a context menu to that control. The Control will likely have a Context property which you can assign a new Context menu to and then items. For example:

    Code:
    System.Windows.Controls.Grid myGrid;
    myGrid.ContextMenu = new System.Windows.Controls.ContextMenu();
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      I wanted to check, are you trying to modify the Tab context menu that you have shown specifically or add a Context to a control you have created in the tab?
      This tab menu specifically. I got it now. Thanks!

      On a related topic, the handler I'm hooking into the new menuitem's click event is to launch a dialog window for preferences of my addon. I could develop mt own Properties dialog and a way to persist the settings in an XML file but why reinvent the wheel...

      Is there a a Properties dialog class available? The experience for the user would be much more consistent. The standard 2 columns, expand/collapse grouping etc.

      Thanks

      Comment


        #4
        Hello xcondor,

        Yes, this is also something I have covered previously, you can find a sample at the following link:

        https://ninjatrader.com/support/foru...24&postcount=2

        As noted in the other post, that is not a complete sample meaning it will not apply changes to the selected indicator completely and likely will produce an error upon using it. The sample is mainly intended to demonstrate what is required to use a property grid and selecting an object that has properties. In your use case for settings, your settings object that is selected in the property grid would be much less complex than the internal indicators which should remove the error portion of that sample. You would also be able to control the properties of your custom object completely unlike the sample that uses an indicator.

        For saving properties of your objects, you have a few options. You can use standard C# xml serialization, I covered this here: https://ninjatrader.com/support/foru...36&postcount=6

        For add-ons, you can use the persistence interface: https://ninjatrader.com/support/help...acePersistence

        I have attached a sample of using addon persistence for general serialization as it appears I have not yet uploaded this to the forum. The persistence sample simply demonstrates an addon with some text fields. You can enter text and save the workspace, upon loading the workspace the text is restored.


        I look forward to being of further assistance.
        Attached Files
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by saltminer, Today, 05:19 PM
        0 responses
        3 views
        0 likes
        Last Post saltminer  
        Started by martyn73, Today, 04:18 PM
        0 responses
        2 views
        0 likes
        Last Post martyn73  
        Started by aprendiz, Today, 03:42 PM
        0 responses
        2 views
        0 likes
        Last Post aprendiz  
        Started by 1001111, Today, 09:10 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by usero86, Today, 06:02 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Working...
        X