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

UserControl alternative for NT8

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

    UserControl alternative for NT8

    in NT7 , I had a script like this:

    UserControl xyz ....
    xyz.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    xyz.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    xyz.Controls.Add(myGroupBox);
    xyz.Margin = new System.Windows.Forms.Padding(2);
    xyz.Name = "Panel";
    xyz.Size = new System.Drawing.Size(123, 123);
    ChartControl.Controls.Add(xyz);


    So, in NT8, i am trying to find alternative, but having some problems. in NT8, i typically use UIElement, however it doesnt have properties (which are marked in RED COLOR above). So, what is the viable alternative?

    #2
    Hello ttodua,

    Thank you for the post.

    NT8 uses WPF which is the newer window framework used in C#. For these type of properties you can generally search online using google to see what the WPF equivalent is for windows forms controls.

    The items you highlighted are not all going to exist and different concepts may replace them.

    The autoscale is not used, you could research using different items like Grids instead to position controls. Depending on the control you are referencing it may have a Margin. UIElement is a base type so if you are trying to work with a control you should use its type instead like Button or Grid etc. That gives the properties specific to that type which may include margins.

    Size for controls is generally controlled by the container like a grid. You can specify Height and Width for a control to make a static size.

    To learn WPF/how positioning works I can suggest to use visual studio outside of NinjaTrader to make a WPF application for testing. You don't have to make it do anything its just so you can use the WPF xaml designer.

    In visual studio you can use the xaml editor and designer to drag and drop controls into the xaml page. That will help to learn what controls are named and how they are used, you can also see all properties for each control in the designer to know whats possible. Based on the xaml you make you could use that as a reference to make the C# code behind for each control to build it like you are doing in the sample you provided.

    To find how to make a WPF control in code you can try searching online for something like "wpf create button programmatically" to get some examples of creating a control in C# code like you have shown.

    Here are some links to examples that use WPF controls in NinjaTrader:
    https://ninjatrader.com/support/help...t_overview.htm (AddOn Framework NinjaScript Basic )
    Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've





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

    Comment


      #3
      Can't imagine if there could have exist better answer than this. Clear, knowledge-directions and everything I needed. Jesse, as always, fantastic answer. thnx.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fitspressoburnfat, Today, 04:25 AM
      0 responses
      2 views
      0 likes
      Last Post fitspressoburnfat  
      Started by Skifree, Today, 03:41 AM
      1 response
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      604 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Working...
      X