cTrader Desktop 5.0.21: Panel does not resize if inner elements get hidden

Created at 21 May 2024, 18:39
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!
WO

wolters

Joined 25.03.2022

cTrader Desktop 5.0.21: Panel does not resize if inner elements get hidden
21 May 2024, 18:39


In the latest version, the graphical UX elements do not work as expected.

Hiding an element inside a panel does not cleanup the used space anymore. So the hiding a panel (IsVisible=false) does not redraw the container of that panel and collapses to the correct size.
As you can see, hiding the inner pannel does not move the lower content up anymore! Please fix this asap, because I cannot use the indicator anymore!

 


@wolters
Replies

PanagiotisCharalampous
22 May 2024, 05:21

Hi there,

Can you share the indicator code so that we can reproduce this behavior?

Best regards,

Panagiotis


@PanagiotisCharalampous

wolters
22 May 2024, 08:54

RE: cTrader Desktop 5.0.21: Panel does not resize if inner elements get hidden

PanagiotisCharalampous said: 

Hi there,

Can you share the indicator code so that we can reproduce this behavior?

Best regards,

Panagiotis

Good morning Panagiotis,

here is an example code:

using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
    public class Test : Indicator
    {
        protected override void Initialize()
        {
            Panel innerPanel1 = new StackPanel();            
            var innerGrid = new Grid(3, 2);

            TextBlock textBlock1 = new();
            textBlock1.Text = "Cell 1";
            textBlock1.BackgroundColor = Color.Gold;

            TextBlock textBlock1b = new();
            textBlock1b.Text = "Cell 2";
            textBlock1b.BackgroundColor = Color.Aqua;

            Button button1 = new();
            button1.Text = "Click me - it shoud collapse the invisible row but it does not anymore with 5.0.21.";
            button1.Click += args =>
            {
                textBlock1.IsVisible = !textBlock1.IsVisible;
                textBlock1b.IsVisible = textBlock1.IsVisible;
            };

            innerGrid.AddChild(button1, 0, 0, 1, 2);
            innerGrid.AddChild(textBlock1, 1, 0);
            innerGrid.AddChild(textBlock1b, 1, 1);
            innerPanel1.AddChild(innerGrid);


            var innerGrid2 = new Grid(2, 1);
            Panel innerPanel2 = new StackPanel();            
            TextBlock textBlock2 = new();
            textBlock2.Text = "Col-Span-Cell";

            Button button2 = new();
            button2.Text = "Click me - it shoud collapse the invisible row but it does not anymore with 5.0.21.";
            button2.Click += args =>
            {
                textBlock2.IsVisible = !textBlock2.IsVisible;
            };

            innerGrid2.AddChild(button2, 0, 0, 1, 2);
            innerGrid2.AddChild(textBlock2, 1, 0, 1, 2);
            innerPanel2.AddChild(innerGrid2);


            Panel innerPanel3 = new StackPanel();            
            TextBlock textBlock3 = new();
            textBlock3.Text = "No grid";

            Button button3 = new();
            button3.Text = "Click me - even without a grid, it will not collapse the invisible textblock anymore.";
            button3.Click += args =>
            {
                textBlock3.IsVisible = !textBlock3.IsVisible;
            };

            innerPanel3.AddChild(button3);
            innerPanel3.AddChild(textBlock3);


            Panel mainPanel = new StackPanel();
            mainPanel.AddChild(innerPanel1);    // with grid selecting only one cell
            mainPanel.AddChild(innerPanel2);    // with grid selecting only one cell
            mainPanel.AddChild(innerPanel3);
            
            mainPanel.AddChild(new TextBlock
                 {
                     Text = "Does not move even if elements are completely hidden.",
                     TextAlignment = TextAlignment.Center,
                     Margin = 5,
                     ForegroundColor = Color.Black,
                     FontWeight = FontWeight.ExtraBold
                 });
            
            mainPanel.IsVisible = true;

            StackPanel tradePanelFrame = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                BackgroundColor = Color.LightBlue,
                Margin = 50,                
            };
            tradePanelFrame.AddChild(mainPanel);
            Chart.AddControl(tradePanelFrame);
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = 
        }
    }
}


@wolters

PanagiotisCharalampous
22 May 2024, 10:47

Hi wolters,

Thank you. We will check and resolve in an upcoming update.

Best regards,

Panagiotis


@PanagiotisCharalampous