Announcement

Collapse
No announcement yet.

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.

    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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X