Stackpanel location properties

Created at 19 Oct 2020, 20:52
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
GE

genappsforex

Joined 25.11.2019

Stackpanel location properties
19 Oct 2020, 20:52


Stackpanel does not have its location properties filled (top,left,width,height,right,bottom)
Could you please fix that?


@genappsforex
Replies

PanagiotisCharalampous
20 Oct 2020, 08:55

Hi genappforex,

Please provide more information about the problem e.g. steps to reproduce.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

genappsforex
20 Oct 2020, 17:32

RE:

using System;
using cAlgo.API;
using cAlgo.API.Requests;
using cAlgo.API.Internals;


namespace cAlgo
{
    [Robot(AccessRights = AccessRights.None)]
    public class Test : Robot
    {
        Button TestButton;
        StackPanel stackPanel;
        
        protected override void OnStart()
        {
            Print("Set Button");
            TestButton = new Button();
            TestButton.Margin = 3;
            TestButton.Text="Test";
            
            stackPanel = new StackPanel
            {
                Width = 120,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            
            stackPanel.AddChild(TestButton);
            Chart.AddControl(stackPanel);
            Print("Buttons set:"+stackPanel.Left,stackPanel.Right,stackPanel.Top,stackPanel.Bottom,stackPanel.Width,stackPanel.Height);
        }

        protected override void OnTick()
        {
            Print("Tick:"+stackPanel.Left,stackPanel.Right,stackPanel.Top,stackPanel.Bottom,stackPanel.Width,stackPanel.Height);
            Stop();
    
        }
    }
}

 

 


@genappsforex

PanagiotisCharalampous
21 Oct 2020, 08:06

Hi genappforex,

I am not sure what do yo think the problem is. You have not initialized these parameters, that's why they are NaN. If you initialize them, you will see them

using System;
using cAlgo.API;
using cAlgo.API.Requests;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Robot(AccessRights = AccessRights.None)]
    public class Test : Robot
    {
        Button TestButton;
        StackPanel stackPanel;

        protected override void OnStart()
        {
            Print("Set Button");
            TestButton = new Button();
            TestButton.Margin = 3;
            TestButton.Text = "Test";

            stackPanel = new StackPanel
            {
                Width = 120,
                Left = 10,
                Right = 10,
                Top = 10,
                Bottom = 10,
                Height = 10,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            stackPanel.AddChild(TestButton);
            Chart.AddControl(stackPanel);
            Print("Buttons set:" + stackPanel.Left, stackPanel.Right, stackPanel.Top, stackPanel.Bottom, stackPanel.Width, stackPanel.Height);
        }

        protected override void OnTick()
        {
            Print("Tick:" + stackPanel.Left, stackPanel.Right, stackPanel.Top, stackPanel.Bottom, stackPanel.Width, stackPanel.Height);
            Stop();
        }
    }
}

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous