Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to work with grids?

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

    how to work with grids?

    Hello
    I haven't yet understood how to work with grids. Taking this example, I would like to know."https://forum.ninjatrader.com/forum/...785#post771785


    Code:
    //Line 83
        System.Windows.Controls.Grid chartTraderGrid = ((Window.GetWindow(ChartControl.Parent).FindFirst("ChartWindowChartTraderControl") as ChartTrader).Content as System.Windows.Controls.Grid).Children[0] as System.Windows.Controls.Grid;
    
    
    
    
                BuyMarketButton = chartTraderGrid.FindFirst("ChartTraderControlQuickBuyMarketButton") as System.Windows.Controls.Button;
    
                SellMarketButton = chartTraderGrid.FindFirst("ChartTraderControlQuickSellMarketButton") as System.Windows.Controls.Button;
    
                Print(chartTraderGrid.RowDefinitions.Count);​
    I have several questions that I haven't found an answer to:
    1. Is it possible to find the names "ChartTraderControlQuickSellMarketButton, ChartTraderControlQuickBuyMarketButton..." without using Inspect?
    2. How do I iterate through the elements (next, previous,last)?
    3. I have add this line:
      Code:
       Print(chartTraderGrid.RowDefinitions.Count);
      The result is 11, but I don't know how it found 11 rows in the chart.

      thank for your help

    #2
    Hello aekzof,

    You would need to use inspect or Accessibility Insights to locate ids in the platform. That is the easiest way to locate ids by selecting a specific control. Unless you know C#/ WPF very well to write your own C# logic to navigate the visual tree that would be the only way. This is something you could research in external C# websites if you wanted to learn more about automation ids and the WPF visual tree.

    Your print is printing the count of the definitions in the grid, there are 11 rows in your current grid. The grid you are looking at is the chart trader control which has many rows and columns to support the other WPF controls it contains.

    You can learn more about using WPF grids in external C#/WPF learning resources.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    152 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    304 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    345 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    175 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X