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

How to add ntgrid to XAML

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

    How to add ntgrid to XAML

    I have been following this example - https://ninjatrader.com/support/foru...545#post726545

    Works very well. But what I am looking for, is to load x4 of those tables in 4 columns that I have in an addon which uses xaml.

    Can someone point me in the right direction on how to:

    1) Define an NTGrid in my XAML addon
    2) Quickly explain how to (in C#) load the ntgrid and set the .DataSource for it (I use a ObservableCollection)

    I have some experience using infragistics components in NT. E.G. I use the following to load the datepicker:

    Xaml:
    Code:
    <Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                                    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                                    xmlns:t='clr-namespace:NinjaTrader.Gui.Tools;assembly=NinjaTrader.Gui'
                                    xmlns:system='clr-namespace:System;assembly=mscorlib'
                                xmlns:ie='http://infragistics.com/Editors'>
    ...
    <ie:XamDateTimeEditor x:Name='datePicker' Grid.Column='1' Grid.Row='0' Width='110' Margin='0, 0, 0, 0' HorizontalAlignment='Right' VerticalAlignment='Top' VerticalContentAlignment='Center' HorizontalContentAlignment='Center' IsAlwaysInEditMode='True' Mask='{}{date}'></ie:XamDateTimeEditor>
    C#:
    Code:
    private Infragistics.Windows.Editors.XamDateTimeEditor datePicker;
    ...
    datePicker = LogicalTreeHelper.FindLogicalNode(pageContent, "datePicker") as Infragistics.Windows.Editors.XamDateTimeEditor;
    datePicker.Value = DateTime.Today;
    Haven;t been able to figure out how to adjust to use NTgrid. Anybody got any pointers?
    Last edited by TradingRocks; 02-17-2020, 04:39 PM.

    #2
    Hello TradingRocks,

    I will provide what I can on this topic however being that this is not a supported or documented control and this is more advanced WPF development the information will be very limited here.

    To use controls in xaml directly you would need to use the namespace as an xmlns similar to what you have show and then define the control in your xaml. We don't have a specific example that uses xaml and an NTGrid for me to provide so all I can really say here is that you have understood the general concept in your post however you may need to change some of what you are doing to execute it correctly.

    XAML and WPF development are not subjects that our support can go into detail on but you can learn about using namespaces/creating elements in xaml in external C# learning resources. You would need to do something very similar to what you had shown. I could suggest looking at the external visual studio sample if you wanted to learn more about xaml and NinjaTrader controls: https://ninjatrader.com/support/help...t_overview.htm

    If you have otherwise tried something that did not work I would need to see what you tried along with the errors you had seen to further the question from that point.


    Regarding the datasource, that is also something you would essentially need to figure out as that grid is not specifically something which was exposed for NinjaScript use. In the linked sample the control is created in C# code so you can assign the datasource directly using that property. If you wanted to do that in xaml without code behind I couldn't provide any suggestions for that use case. You would likely need to find the control and use its instance like you have shown in your second code example however in your explained use it would be 4 grids you are finding and having 4 variables for those grids.



    Please let me know if I may be of additional assistance.






    JesseNinjaTrader Customer Service

    Comment


      #3
      Sorry I'm late to this discussion... if you haven't figured it out yet, here's how I have it working, and bound to a table
      In my window class,
      Code:
      private NTGrid dg1;
      public DataTable trades = new DataTable();
      Xaml:
      Code:
      xmlns:t="clr-namespace:NinjaTrader.Gui.Tools;assembly=NinjaTrader.Gui"
      .
      .
      <t:NTGrid t:Name="dg1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoFit="true">
      Code:
      Code:
      dg1 = LogicalTreeHelper.FindLogicalNode(page, "dg1") as NTGrid;
      dg1.DataSource = trades.DefaultView;
      I have not used with an ObservableCollection...that will make the DataSource line a bit different, but the rest is pretty basic.
      Hope it helps,
      T.
      Last edited by tgn55; 11-03-2020, 01:39 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      5 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X