Parent StackPanel is not auto resized when child StackPanel.IsVisible=false (cTrader v5.0.21, Algo v1.0.9)

Created at 18 May 2024, 17:29
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!
TO

tomas.malukas.work

Joined 14.07.2023

Parent StackPanel is not auto resized when child StackPanel.IsVisible=false (cTrader v5.0.21, Algo v1.0.9)
18 May 2024, 17:29


Hi Team,

Recently noticed when child StackPanel.IsVisible=false then parent container (e.g. StackPanel) still holds child stackpanel space while in ctrader v4 it was automatically auto resized like with property MaxWidth = 0.

Here in screenshot it clearly visible that Border should be auto resized to just button btnShowHide (it was with cTrader v4) when stackpanel.isVisible=false

Results:

  1. Before (StackPanel.IsVisible=true)
  2. After(StackPanel.IsVisible=false)
  3. Expected: border should auto resize to btnShowHide as there is nothing visible (thats how it was working with ctrader v4)

SourceCode

using System;
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
    public class cBotTest : Robot
    {
        Canvas canvasTopMost = new();
        Canvas canvasMain = new() { Top = 10, Left = 10 };
        Border border = new() { BorderThickness = 1, BorderColor = Color.White};
        StackPanel stackHmain = new() { Orientation = Orientation.Horizontal };
        StackPanel stackHchild = new() { Orientation = Orientation.Horizontal };
        
        Button btnShowHide = new() { Text = "btnShowHide", };
        Button btnChild1 = new() { Text = "btnChild 1", };
        Button btnChild2 = new() { Text = "btnChild 2", };
        Button btnChild3 = new() { Text = "btnChild 3", };        

        protected override void OnStart()
        {
            Chart.AddControl(canvasTopMost);

            canvasTopMost.AddChild(canvasMain);
            canvasMain.AddChild(border);     
            border.Child = stackHmain;

            stackHmain.AddChild(btnShowHide);
            stackHmain.AddChild(stackHchild);
            btnShowHide.Click += e => { stackHchild.IsVisible = !stackHchild.IsVisible; };

            stackHchild.AddChild(btnChild1);
            stackHchild.AddChild(btnChild2);
            stackHchild.AddChild(btnChild3);
        }

        protected override void OnTick()
        {
            
        }

        protected override void OnStop()
        {
            
        }
    }
}

@tomas.malukas.work
Replies

PanagiotisCharalampous
20 May 2024, 10:02

Hi there,

Thank you for reporting this issue. We will resolve this in an upcoming update.

Best regards,

Panagiotis


@PanagiotisCharalampous

winsonet
20 May 2024, 15:03

I also have the same issue, after I tried to invisible the elements (the Border in my case), it will still occupy the position and break my layout, hope can fix it ASAP, thanks!


@winsonet

prihod007
21 May 2024, 06:10

RE: Parent StackPanel is not auto resized when child StackPanel.IsVisible=false (cTrader v5.0.21, Algo v1.0.9)

PanagiotisCharalampous said: 

Hi there,

Thank you for reporting this issue. We will resolve this in an upcoming update.

Best regards,

Panagiotis

 

I support you, this problem is relevant to me too


@prihod007